Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old July 29th, 2004, 03:08 PM
rhpos rhpos is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: Midwest
Posts: 93 rhpos User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 h 17 m 29 sec
Reputation Power: 6
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">&nbsp;&nbsp;&nbsp;<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?

Reply With Quote
  #2  
Old September 14th, 2004, 01:38 AM
2ckelvin 2ckelvin is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 4 2ckelvin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #3  
Old September 20th, 2004, 02:39 PM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
don't use innerHTML - it's not standards compliant. Use the DOM properly

christo

Reply With Quote
  #4  
Old September 20th, 2004, 05:45 PM
ChiefWigs1982's Avatar
ChiefWigs1982 ChiefWigs1982 is offline
Cunning Linguist
Dev Shed God 10th Plane (9500 - 9999 posts)
 
Join Date: Jul 2003
Location: I used to live at home, now I stay at the house
Posts: 9,894 ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)ChiefWigs1982 User rank is Lieutenant General (80000 - 90000 Reputation Level)  Folding Points: 50746 Folding Title: Beginner FolderFolding Points: 50746 Folding Title: Beginner FolderFolding Points: 50746 Folding Title: Beginner Folder
Time spent in forums: 3 Months 2 Weeks 5 Days 14 h 37 m 57 sec
Reputation Power: 820
Facebook
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!
Sites: Route of Queue | Sinthetic - Alternative UK Hiphop
Read These: The General Rules Thread | The General FAQ Thread | NEW USERS - How to post a question

Sign up with Matched.co.uk and earn up to £15 per website every month!


Reply With Quote
  #5  
Old January 15th, 2005, 04:52 AM
libdanz libdanz is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 3 libdanz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > How do I use innerHTML?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway