|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
How do I use innerHTML?
I am using VBScript in a web page to access a database and
return a recordset which I wish to use to repopulate a table column. I thought I could use innerHTML or innerTEXT to do that but it is simply not working. The code: <Script Language="VBScript"> Sub DoSel Dim conn, pininfo Const adOpenStatic = 3 Const adLockOptimistic = 3 Const adUseClient = 3 Set conn = CreateObject("ADODB.Connection") Set rs = CreateObject("ADODB.Recordset") conn.Open "DSN=Pintest;" conn.CursorLocation = adUseClient rs.Open "SELECT * FROM Table1 WHERE Ident='"& document.DBSelectForm.pininfo.value &"'" , conn, adOpenStatic, adLockOptimistic document.getElementByID[my1].innerHTML = "& rs('Ident') &" document.getElementByID[my2].innerHTML = "& rs('Username') &" document.getElementByID[my3].innerHTML = "& rs('Password') &" document.getElementByID[my4].innerHTML = "& rs('Pin') &" document.getElementByID[my5].innerHTML = "& rs('Key') &" document.getElementByID[my6].innerHTML = "& rs('Type') &" rs.Close conn.Close End Sub </script> <h3>Update Pin Database</h3> <FORM NAME="DBSelectForm" OnSubmit="DoSel()"> <p>Select an Ident: <INPUT TYPE="TEXT" NAME="pininfo"> <input TYPE="Submit" VALUE="Submit"> </FORM> <table cellspacing=0 cellpadding=5 border=1> <th>Field<th>Value <tr><td>Ident</td><td id="my1"><br></td></tr> <tr><td>Username</td><td id="my2"><br></td></tr> <tr><td>Password</td><td id="my3"><br></td></tr> <tr><td>Pin</td><td id="my4"><br></td></tr> <tr><td>Key</td><td id="my5"><br></td></tr> <tr><td>Type</td><td id="my6"><br></td></tr> </table> As yu can see, I originally print the table with <br>'s in the column I wish to change. After selecting an identifier I try to use innerHTML to change the <br>'s to the values obtained from the recordset. There are no errors upon script loading and I know the data is being retrieved since I can dynamically write the table in the script. The table doesn't change after I hit the submit button. Can anyone tell me why this will not work? |
|
#2
|
|||
|
|||
|
I can only tell you why it does not work. I am also new here
innerHTML is javascript May be you can get more help from HTML Programming forum. ![]() |
|
#3
|
||||
|
||||
|
don't use innerHTML - it's not standards compliant. Use the DOM properly
christo
__________________
. Spiration channels: Free scripts, programming tutorials and articles Dotcut alerts: Online Press cuttings / news alerts Clearprop: UK microlight school, wiltshire Uk dating: UK safe dating with Topdates About Christo . . |
|
#4
|
||||
|
||||
|
Yeah, Christo is technically right, innerHTML is not standard, it was invented by the good old folks at M$, along with stuff like iFrames, but it turns out it's pretty useful and really handy, so pretty much all browsers adopted it, and now all support it.
What you are doing is just wrong though. You are already using ASP to write the doc, so why not use it to fill in the <td>'s? Code:
rs.Open "SELECT * FROM Table1 WHERE Ident='"& document.DBSelectForm.pininfo.value &"'" , conn, adOpenStatic, adLockOptimistic
Loop of some sort
Response.Write('<table cellspacing=0 cellpadding=5 border=1>');
Response.Write('<tr><td>Ident</td><td id='& rs('Ident') &'><br></td></tr>');
Response.Write('<tr><td>Username</td><td id='& rs('Username') &'><br></td></tr>');
Response.Write('<tr><td>Password</td><td id='& rs('Password') &'><br></td></tr>');
Response.Write('<tr><td>Pin</td><td id='& rs('Pin') &'><br></td></tr>');
Response.Write('<tr><td>Key</td><td id='& rs('Key') &'><br></td></tr>');
Response.Write('<tr><td>Type</td><td id='& rs('Type') &'><br></td></tr>');
Response.Write('</table>');
End loop
rs.Close
conn.Close
End Sub
Try that...
__________________
Support requests via PM will be ignored! |
|
#5
|
|||
|
|||
|
You missed something
You should understand where to use Server Side scripts and Client Side Scripts. The document.getElementByID[my1].innerHTML is a client side property that will only be resolved in the browser. So to incorporate it in your scripts you can do it like this.
<script language="Javascript"> <% Response.Write("document.getElementByID[my1].innerHTML ="& rs('Ident')) %> </script> etc |
![]() |
| Viewing: Dev Shed Forums > Web Site Management > Scripts > How do I use innerHTML? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|