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

onChange no longer works 1

Status
Not open for further replies.

lilboi

Programmer
Joined
Dec 22, 2003
Messages
146
Location
CA
Hi guys!

This is a weird problem because I have the same code where the onChange works for this server, but doesn't work on the server that I recently set up.

The asp codes work. The onChange I have is on a select drop down list.


Code:
<select name="changeClient" onChange="location.href=(form.changeClient.options[form.changeClient.selectedIndex].value)">

This one worked on the old server but not on the new one. Could it be a javascript thing that was not set to be run on the server or would it be the browsers that have it off?

As well I have a button coded as

Code:
<input type="submit" name="submit" value="Send Message" onClick="sendmsg.asp?id=1">

That one doesn't work either. Any inputs will be so helpful.

Thanks!
 
This:

Code:
onClick="sendmsg.asp?id=1"

is totally invalid. "sendmsg.asp?id=1" is not valid JavaScript - it simply a URL. onclick handlers should take valid script.

If you want the select element to simply change the URL, then use this:

Code:
<select name="changeClient" onchange="location.href = this.value;">

If you want the submit button to submit to the URL you previously had in the onclick handler, you should remove the onclick from the button and move the content to the form's action:

Code:
<form action="sendmsg.asp">
   <input type="submit" name="mySubmit" value="Send Message">
</form>

Hope this helps,
Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
This is awesome! It all works now! And I thought it must've been the server's javascript. hehe

You's the man, Dan!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top