Wrox Programmer Forums
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 20th, 2005, 07:59 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

> Well, you can't do that. A textarea can only contain plain text, i.e. no tags.

That's not true. Most web-based WYSIWYG editors work using textareas, where the content of the textarea is copied to an inline frame for visual editing, and the textarea itself is used for "view source" mode. In my own experience the only tags a textarea cannot contain are nested textareas, the browser gets confused and closes the first one upon encountering the first closing tag.

It would help more to see a link to the output of the script.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old May 20th, 2005, 08:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Yes, I know it works in practice. But the case you describe is user input. Not coded in HTML. IIRC the content of textarea is #PCDATA, so if you want it to be valid the tags should be escaped. No doubt it works in all or most browsers anyway.

(o<
//\ =^..^=
 
Old May 20th, 2005, 08:40 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

no, sorry. it is coded in the ASP page. here is the code:
Code:
        <textarea name="Content" cols="100" rows="6" wrap="PHYSICAL" style="font-family:Verdana, Arial, Helvetica, sans-serif; text-align:left"><%=trim(rs("Content"))%></textarea>
can i still not be left-aligned? i have tried 'trim'

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
 
Old May 20th, 2005, 08:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 425
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Wait, I think I get what you mean now crmpicco. Better late than never, huh?

When the script is parsed it probably leaves some whitespace in the beginning of the form. Since spaces do render in a textarea... Could that be it? See if you can select the whitespace with your mouse.

(o<
//\ =^..^=
 
Old May 20th, 2005, 08:55 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

yes, i can highlight the whitespace with my mouse

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
 
Old May 20th, 2005, 08:58 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Sure, we are talking tag soup here, right?

I think the best way to go about it is to put the HTML off to the side in a separate containing <div> (with default display: none), and then populate the <textarea> from script by reading the contents of that <div>. That takes care of validation errors, and also troubles with nested textareas.

Course the best way to go about populating the textarea from the div is via the non-standard (or defacto standard) innerHTML property. In these types of applications though, standards tend to go out the window because browser support is so varying. WYSIWYG only works on either the proprietarty Microsoft MSHTML, or Mozilla Midas platforms anyway. I heard Safari has one too now, but I don't know what they're calling it. So interoperability is limited by circumstance and lack of standardization.

I've also heard that HTML 5 will address many issues like this, e.g. the DOCTYPE not allowing certain elements to live inside of certain other elements, standardization of the innerHTML property, etc.

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old May 20th, 2005, 09:49 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

how do i do that? this is how my table looks:
Code:
<table bgcolor="#ececec" border="1" bordercolor="#000000" align="center">
    <tr bordercolor="#ececec">
      <td colspan="3"><div align="center"><span class="style6">Rule <%=cint(a)+1%> </span></div></td>
    </tr>
    <tr bordercolor="#ececec">
      <td width="185"><div align="right" class="style3">Heading</div></td>
      <td width="1">&nbsp;</td>
      <td width="559"><div align="left">


<input name="heading<%=a%>" id="heading<%=a%>" type="text" size="100" value="<%=fix_characters(ucase(trim(rulexml.selectnodes("rules").item(0).selectnodes("fare_rule_lines").item(a).selectnodes("heading").item(0).text)))%>" style="font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif">
      </div></td>
    </tr>
    <tr bordercolor="#ececec">
      <td><div align="right" class="style3">Content</div></td>
      <td>&nbsp;</td>
      <td align="left"><div align="left">
        <textarea name="content<%=a%>" id="content<%=a%>" cols="100" rows="5" wrap="PHYSICAL" style="font-family:Verdana, Arial, Helvetica, sans-serif; text-align:left">
        <%

        if left(rulexml.selectnodes("rules").item(0).selectnodes("fare_rule_lines").item(a).selectnodes("content").item(0).text,15) <> "<table><tr><td>" then

            '... if the airline is CSA Czech Airlines then create a table 
            '... with a border
            if airline_code = "OK" then
            response.write "<table border=1 bordercolor=000000><tr>"
            else
            not_CSA_CzechAirlines = true
            response.write "<table><tr><td>" ' border=1 bordercolor=#000000
            end if

        end if
        %> 
        <%=fix_characters(rulexml.selectnodes("rules").item(0).selectnodes("fare_rule_lines").item(a).selectnodes("content").item(0).text)%>
        <%
        ' if there is no end table tag then create one to end the table
        if right(rulexml.selectnodes("rules").item(0).selectnodes("fare_rule_lines").item(a).selectnodes("content").item(0).text,18) <> "</td></tr></table>" then
        response.write "</td></tr></table>"
        end if 
        %>
        </textarea>
      </div></td>
    </tr>
    <% 'end if %>
    <tr bgcolor="#000000" height="3">
      <td colspan="3"></td>
    </tr>


 
<%
Set rs = con.Execute("select Max(RuleSeq) Ref from farerulelines where RuleId = '" &trim(request.form("contract_id"))& "' and CompanyId='"& comp_code &"'")
            'response.write "Ref = " & rs("Ref") & "<br>" 
            If isNull(rs("Ref")) Then
                iMaxKeyRef = 0
            Else
                iMaxKeyRef = CLng(rs("Ref"))
            End If
            iMaxKeyRef = iMaxKeyRef + 1
            fare_id = right("0000" & iMaxKeyRef, 4)     

'if count_rows = 0 then
set rs=con.execute("insert farerulelines (RuleId, RuleSeq, CompanyId) values ('" & trim(request.form("contract_id")) & "', '" & fare_id & "'  , '"& comp_code &"' )")
'response.Write ("insert farerulelines (RuleId, RuleSeq, CompanyId) values ('" & trim(request.form("contract_id")) & "', '" & fare_id & "'  , '"& comp_code &"' )")&"<br>"
set rs1=con.Execute ("update farerulelines set Heading = '"&fix_characters(request.form("heading"&a))&"', Content = '"&fix_characters(request.form("content"&a))&"' where RuleId='" & trim(request.form("contract_id")) & "' and RuleSeq ='" & fare_id & "' and CompanyId ='"& comp_code &"'")
'response.Write ("update farerulelines set Heading = '"&fixquotes(request.form("heading"&a))&"', Content = '"&fixquotes(request.form("content"&a))&"' where RuleId='" & trim(request.form("contract_id")) & "' and RuleSeq ='" & fare_id & "' and CompanyId ='"& comp_code &"'")
'end if
next 
' main loop
%>
 
    <tr>
      <td align="center" colspan="10">
      <div align="center">   
      <input type="hidden" name="show_extras" id="show_extras" value="no">    
<input type="submit" name="Submit" value="Submit" onmouseover="style.cursor='hand'">

      </div></td>
    </tr>
    <% if show_extras = "no" then %>
    <tr>
      <td colspan="10">
      <div align="center">       
<a href="fareloaderrules_edit.asp?contract_id=<%=trim(request.Form("contract_id"))%>">VIEW</a>
      </div></td>
    </tr>
    <% end if %>
      </table>
www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
 
Old May 20th, 2005, 10:06 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

How do you do what? This question is too open-ended!

As to the alignment inquiry, honestly it helps to see the output of the script. Currently we can only guess what's happening there. You can post what you think is the relevant server-side code till you're blue in the face, and that won't change the fact that it could be things outside of the textarea that are affecting its alignment.

As to populating the textarea, if validation matters to you, output the table to a div like so:
Code:
<div id='markup' style='display: none;'>

</div>
<textarea id='whatever_name' name='whatever_name'></textarea>
<script type='text/javascript'>
     // Populate the textarea with the contents of the div.
     document.getElementById('whatever_name').value = document.getElementById('markup').innerHTML;
</script>
> Can someone tell me where i can find that character on the keyboard?

That looks like a Microsoft Word generated "smart-quotes" apostrophe, which does not inhabit standard ASCII. Turn off the "smart quotes" feature of Word to eliminate that (Tools -> AutoCorrect Options-> AutoFormat As You Type).

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old May 20th, 2005, 10:12 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Ah, never mind found it.

right single quote mark 92 #146; &rsquo; --> ’
http://www.bbsinc.com/iso8859.html

(still a Microsoft added character though, and best to avoid)

Regards,
Rich

--
[http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design
 
Old May 24th, 2005, 05:33 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

how can i get my IP to allow you to view it then?

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt





Similar Threads
Thread Thread Starter Forum Replies Last Post
text-align:justify; and <BR> anshul HTML Code Clinic 23 June 18th, 2018 03:04 AM
CSS Text Align webnitro CSS Cascading Style Sheets 3 December 8th, 2005 01:19 PM
Align IMG with text Snib HTML Code Clinic 12 April 8th, 2004 10:16 AM
Align text acko ASP.NET 1.x and 2.0 Application Design 2 January 9th, 2004 10:21 AM
Right align text in labels in a templatecolumn texasraven ASP.NET 1.x and 2.0 Application Design 1 August 27th, 2003 08:44 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.