asherinho
08-27-2008, 01:34 PM
Hi! can anyone help me here,whats wrong with the codes below.I want to direct user to another page tryn2.html or tryn3.html depending on the selection user made in the select field.The window.location() function doesn't work the way it should be
html>
<head><title>clr</title>
<script type="text/javascript">
function validate_form ( ){
if ( document.myform.nam.selectedIndex == 1 )
{
var valid=confirm ( "Are u sure?" );
if(valid==true){
window.location=("tryn2.html");
}else{
window.location=('tryn3.html');
}
}
}
</script>
</head>
<body>
<form name="myform" onSubmit="return validate_form ( );">
<select name="nam">
<option>Select one..</option>
<option>Delete</option>
<option>George</option>
</select>
<input type="submit" value="submit">
</form>
</body>
<html>
html>
<head><title>clr</title>
<script type="text/javascript">
function validate_form ( ){
if ( document.myform.nam.selectedIndex == 1 )
{
var valid=confirm ( "Are u sure?" );
if(valid==true){
window.location=("tryn2.html");
}else{
window.location=('tryn3.html');
}
}
}
</script>
</head>
<body>
<form name="myform" onSubmit="return validate_form ( );">
<select name="nam">
<option>Select one..</option>
<option>Delete</option>
<option>George</option>
</select>
<input type="submit" value="submit">
</form>
</body>
<html>