Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access the value of <SPAN>

Status
Not open for further replies.

AndyApp

Programmer
Dec 20, 2001
259
0
0
GB
I have the following:

<SPAN ID=&quot;myLabel&quot;>whatever</SPAN>

I then assign a value to that using JavaScript:

var f = document.thisForm;
document.getElementById(&quot;myLabel&quot;).innerHTML = f.EnqCode.options[f.EnqCode.selectedIndex].text;

How can I then access the value of the <SPAN> using vbscript? Just:
<% response.write(myLabel)%>
Doesn't do anything. I think the problem is because Javascript has given it the value but is there a way round it?

&quot;Life is like a Ferrari, it goes to fast.
But that's ok, because you can't afford it anyway&quot; - Jim Davis (Garfield)
 
Use the innerText property, as in the following example:

<HTML>
<HEAD>
<SCRIPT LANGUAGE=&quot;VBScript&quot;>
<!--
Sub cmdButton_Click()
window.alert document.all(&quot;myLabel&quot;).innerText
End Sub
-->
</SCRIPT>
</HEAD>
<BODY>
<P>Show Here: <SPAN id=&quot;myLabel&quot;>Test message</SPAN></P>
<P><INPUT id=cmdButton type=button value=&quot;Click Here&quot; onclick=&quot;cmdButton_Click()&quot;></P>
</BODY>
</HTML>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top