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 call functions in response to button or combo click 1

Status
Not open for further replies.

ganusha

Programmer
May 1, 2002
28
US
Hi
i've a button like
<input type=button value=&quot;GO&quot;>
now i need to call a sub routine in the same page in response to the button click.

i've a combo box filled with HomeNo1,HomeNO2,HomeNo3
and everytime i click on any one option, the corresponding no should be displayed in the textbox adjacent to it.
i've written a function to do that.i need to call this function in response to the combo selection.
can anyone help.
Thanks
 
the first question to run the function from the button
<input type=button value=&quot;GO&quot; onClick=&quot;function name&quot;>

the second..you can run the function after a user selects a option with the onChange event
<select onClick=&quot;function name&quot;>
<option>
etc...

like this
<html>
<head>
<script>
function sel() {
alert(&quot;hello!&quot;);
}
</script>
</head>
<body>
<form>
<select onChange=&quot;sel()&quot;>
<option>
<option>one
<option>two
<option>three
</select>
</form>
</body>
</html>
A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
Thanks but does the onclick function work with vbscript??
 
the onClick function does work with vbscript BUT will not work correctly with a select.
everytime the drop arrow is clicked it will fire the event if you use the onClick never giving the user the opurtunity to actually select anything
try this out and you will see what I mean, then change the event to onChange
<html>
<head>
<script language=&quot;vbscript&quot;>
function sel()
alert &quot;hello!&quot;
end function
</script>
</head>
<body>
<form>
<select onClick=&quot;sel()&quot;>
<option>
<option>one
<option>two
<option>three
</select>
</form>
</body>
</html> A language that doesn't affect the way you think about programming is not worth knowing.
admin@onpntwebdesigns.com
 
hi,
This works even without selecting any of the values the the select tag.
How do i get the values of the SELECT tag when i select the options.
thanks, AI
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top