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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use Elements Object/property? 1

Status
Not open for further replies.

Davrem

Technical User
Sep 3, 2002
2
US
Hey everyone I have a relatively simple/newbie question. I have been searching all over Microsoft's VBScript website to find information about the elements object/property. I found one reference from an old book excerpt and even that was not very detailed. Then I also searched on the net but couldn't find anything on the other vbscript sites about it. I came here and found one article about it that Mr. Schulz was nice enough to post but I still have more questions below(after his code).
_____________________________________________________________________________________________________________________________

Here is my favorite method (in vb and java scripts)...

<html>
<script language=&quot;javascript&quot;>
function ChangeColor(){
var z=document.forms.frmDemo
for (var i=0;i<z.elements.length;i++){
z.elements.style.backgroundColor = &quot;#00FF00&quot;
}
}
</script>
<script language=&quot;vbscript&quot;>
Sub btn1_OnClick()
Dim fld

For Each fld in document.forms.frmDemo.elements
fld.style.backgroundcolor = &quot;#FF0000&quot;
Next

End Sub
</script>
<body>
<form id=frmDemo>
<input type=text id=txt1><br>
<input type=text id=txt2><br>
<input type=text id=txt3><br>
<input type=text id=txt4><br>
<input type=text id=txt5><br>
<input type=button id=btn1 value=&quot;Click me&quot;>
<input type=button id=btn2 value=&quot;Click me too&quot; onClick=&quot;ChangeColor();&quot;>
</form>
</body>
</html>

Hope it helps,
Rob
Rob
robschultz@yahoo.com
-Focus on the solution to the problem, not the obstacles in the way.-
_____________________________________________________________________________________________________________________________
Questions:
1. In the example does &quot;fld&quot; represent a HTML control that is stored in an array?
2. How can I find what type of control the loop is iterating at currently?
3. Are &quot;elements&quot; an object or property in the For Each example above?
4. Can someone point me to a website that has more info about controlling HTML controls programmatically especially with an emphasis about the elements ojbect/property?




Thanks in advance for all of your help or suggestions.
David
davrem_2000@yahoo.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top