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

onClick function not working

Status
Not open for further replies.

qasmi

Programmer
Feb 19, 2004
9
PK
I am using a javascript function

<script language="JavaScript">
function myOnChangeDept() {
var list = document.frmDept.selectDepartments;
var listValue = list.options[list.selectedIndex].value;
window.location.href = "view.asp?ID="+listValue;
}
</script>

and calling it at
<input type="submit" name="Submit" value="Submit" onclick="myOnChangeDept()">

but it is not working, this just reloads itself and thats it.

Any ideas?

Qasim

 
Ahhh very easy to fix add the return false;

Code:
<input type="submit" name="Submit" value="Submit" onclick="myOnChangeDept();return false">

this will abort the input's native ability in the browser and just run your on click event

-Pete
Do you get a little guilty pleasure when a celebrity has a bad day?
Well then The Dead Pool is for you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top