table element within a textarea

Discussion in 'Software' started by be0, Jul 17, 2008.

  1. be0

    be0 Corporal

    Hi all,

    Is there a way to add a table element withing a textarea?

    <textareat>
    <table>
    <tr>
    <td>
    .
    .
    .
    .

    </td>
    </tr>
    </table>
    </textarea>
     
    Last edited: Jul 17, 2008
  2. PC-XT

    PC-XT Master Sergeant

    I don't think so, but if you use an iframe instead, you can use html. textarea was basically made for text only. iframes are made for containing another document, but you can use JavaScript to insert, either by writing html to the frame's document object or by giving a url for it as
    Code:
    <iframe src="javascript:'<html><body><table><tr><th>example</th><td>table</td></tr></table></body></html>'">
    The second way tends to yield long url's if you try to use correct xhtml. You also need to be careful to escape quote characters.
     
  3. be0

    be0 Corporal

    Hmmm thanks man.

    However I have this whole mess that I need to put in there. And I have no idea how to do it:

    <table class="ListShort">
    <%if rs.EOF or rs.BOF then %>
    <tr class='Datalight' style='font-size:11px'>
    <td colspan="100" style='font-weight:bold'>
    <br>
    <b><%response.Write("No Data found for prod cat" & cat & "00")%></b>
    </td>
    </tr>
    <%else %>
    <tr class="Section">
    <th colspan="14"><font size = "2">Product Availability by Prod Category <%response.Write(cat & "00") %></font></th>
    </tr>
    <tr class="Separator" >
    <td class="Sep1" colspan="14"></td>
    </tr>


    <tr class = "header">
    <th>&nbsp;</th>
    <th ondrag="" style="white-space:nowrap">Week</th>
    <th style="white-space:nowrap">A </th>
    <th style="white-space:nowrap">A -</th>
    <th style="white-space:nowrap">A %</th>
    <th style="white-space:nowrap;">B </th>
    <th style="white-space:nowrap">B -</th>
    <th style="white-space:nowrap">B %</th>
    <th style="white-space:nowrap">C </th>
    <th style="white-space:nowrap">C -</th>
    <th style="white-space:nowrap">C %</th>
    <th style="white-space:nowrap">All</th>
    <th style="white-space:nowrap">All -</th>
    <th style="white-space:nowrap">All %</th>
    </tr>
    <%
    IsDark =
    true
    If Forward > RS.RecordCount then
    Forward = RS.RecordCount
    end if

    if backwards < 0 then
    Backwards = 0
    end if

    rs.Move(Next10-10)

    do while not rs.EOF and count < Next10
    IsDark =
    not IsDark
    ACount =
    cint(rs("total_A_SKY"))
    ANegCount =
    cint(rs("total_A_NEG_SKU"))
    BCount =
    cint(rs("total_B_SKY"))
    BNegCount =
    cint(rs("total_B_NEG_SKU"))
    CCount =
    cint(rs("total_C_SKY"))
    CNegCount =
    cint(rs("total_C_NEG_SKU"))

    Tcount = ACount+BCount+CCount
    TNegCount = ANegCount+BNegCount+CNegCount

    TPct =
    cint((TCount-TNegCount)/TCount*100)
    APct =
    cint((ACount-ANegCount)/ACount*100)
    BPct =
    cint((BCount-BNegCount)/BCount*100)
    CPct =
    cint((CCount-CNegCount)/CCount*100)


    %>
    <tr class="<%=iif(IsDark,"DataDark","Datalight")%>">
    <%if Next10 - 10 = Count then%>
    <%
    if Backwards <> 0 then %>
    <td><a href="<%response.write(request.ServerVariables("URL") & "?" & EditURL(request.QueryString,"Next", cstr(Backwards), False))%>"><img border ="0" src="images/ArrowUpGreen.gif" title="Previous 10" /></a></td>
    <%else %>
    <td><img border ="0" src="images/ArrowUpGreen.gif" title="Previous 10" /></td>
    <%end if %>
    <%
    elseif count+1 = Next10 then%>
    <%
    if Forward < Rs.RecordCount then %>
    <td><a href="<%response.write(request.ServerVariables("URL") & "?" & EditURL(request.QueryString,"Next",cstr(Forward), False))%>"><img border ="0" src="images/ArrowDownBlue.gif" title="Next 10" /></a></td>
    <%else %>
    <td><img border ="0" src="images/ArrowDownBlue.gif" title="Next 10" /></td>
    <%end if %>
    <%
    else %>
    <td></td>
    <%
    end if %>
    <td style="white-space:nowrap"><%=rs("datestamp")%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(ACount)%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(ANegCount)%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(Apct & "%")%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(BCount)%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(BNegCount)%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(Bpct & "%")%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(CCount)%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(CNegCount)%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(Cpct & "%")%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(TCount)%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(TNegCount)%></td>
    <td style="white-space:nowrap; text-align:center"><%Response.write(Tpct & "%")%></td>

    </tr>

    <%

    count = count + 1
    rs.MoveNext
    loop

    %>
    <%
    end if %>
    <tr>

    <td colspan=14 style="text-align:center;" ><a href ="<%response.write(request.ServerVariables("URL") & "?" & EditURL(request.querystring,"cat","1", fasle))%>">
    <%if cat = "1" then%>
    <b>100</b>
    <%else %>
    100
    <%
    end if %>
    </a>
    <a href ="<%response.write(request.ServerVariables("URL") & "?" & EditURL(request.querystring,"cat","2", fasle))%>">
    <%if cat = "2" then%>
    <b>200</b>
    <%else %>
    200
    <%
    end if %>
    </a>
    <a href ="<%response.write(request.ServerVariables("URL") & "?" & EditURL(request.querystring,"cat","3", fasle))%>">
    <%if cat = "3" then %>
    <b>300</b>
    <%else %>
    300
    <%
    end if %>
    </a>
    <a href ="<%response.write(request.ServerVariables("URL") & "?" & EditURL(request.querystring,"cat","8", fasle))%>">
    <%if cat = "8" then %>
    <b>800</b>
    <%else %>
    800
    <%
    end if %>
    </a>
    </td>
    </tr>
    </table>
     
  4. be0

    be0 Corporal

    If I make a function for all that code and then set the Iframe srouce to vbscript and call that function will that work?
     
  5. PC-XT

    PC-XT Master Sergeant

    I think you can access the iframe element object with vbscript, but it might be easier to put it in a separate document and give the url to that document in the iframe src attribute. This is the primary way iframes were designed to be used. If you still want to use a script in the same document, I usually use
    Code:
    set ifrm1 = document.getElementById("IFrame1")
    I then set ifrm1.document.body.innerText to whatever I want, or write to ifrm1.document. (Of course, "IFrame1" is the id of the iframe in this example.)
     
  6. PC-XT

    PC-XT Master Sergeant

    I just happened to think, the easiest way to do the same thing as a textarea or iframe is to use a div and set its overflow style attribute to auto:
    Code:
    <div style="overflow: auto;">table goes here</div>
    That would produce something similar to an iframe (set the desired width and height for scroll bars) To produce text more like a textarea, I noitice that that code window above uses pre instead of div.
    Code:
    <pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 640px; height: 34px; text-align: left;">&lt;div style="overflow: auto;"&gt;table goes here&lt;/div&gt;</pre>
     
  7. be0

    be0 Corporal

    Sweet. I didnt even know that... wow...
    You do think code. Thanks man.
     
  8. PC-XT

    PC-XT Master Sergeant

    Glad to help. :)

    BTW, if a user happens to have an old browser, the div tag will be ignored, and the table will display in full (unless it's so old that it can't display tables properly ;) ). Iframe's won't display anything in this same case, unless you add extra code, so I guess div's are actually better in most cases.
     
  9. be0

    be0 Corporal

    That worked. Thanks allot man.

    I got another question for ya?

    What is the difference between

    rs.close and rs.close()
    rs.movenext and rs.movenext()

    where rs is a record set?

    Why would that cause my first row not to show up.
    Weird.
     
  10. PC-XT

    PC-XT Master Sergeant


MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds