August 11th, 2003, 02:45 PM
-
Javascript - Error
Hi,
I have the following code, but the script part is not getting executed.... I checked it with an Alert.
<html>
<head>
<title>Sample code</title>
</head>
<body>
<script language="javascript" type="text/javascript">
function CHK_CAT_SELECT(){
var CAT_SLC = document.frm_cat_lst.prod_access_area_frm_slc.options[document.frm_cat_lst.prod_access_area_frm_slc.selectedIndex].value;
if (CAT_SLC!= ""){
alert(CAT_SLC); // make sure it works
// document.frm_mdl_lst.prod_access_mdel_frm_slc.... // set me
return true;
}
function CHK_MDL_SELECT() {
var MDL_SLC = document.frm_mdl_lst.prod_access_mdel_frm_slc.value;
if (MDL_SLC != "") {
return true;
}
}
</script>
<form name="frm_cat_lst" action="http://njitswgt02/scripts/wgate/z_bic_offc/!?~template=bic_prod_access_lst&~event=get_models&prod_cat_area=ZROOT" method="post" onSubmit="return CHK_CAT_SELECT()">
<select name="prod_access_area_frm_slc" onChange="document.frm_cat_lst.submit()">
<option>select a product category</option>
<option value="ZCAT01" >Printers</option>
<option value="ZCAT02" >Fax</option>
<option value="ZCAT03" >Multi-Function</option>
<option value="ZCAT04" >P-touch Labeling</option>
<option value="ZCAT05" >Laminators</option>
<option value="ZCAT06" >Stamp Creator</option>
</select>
</form>
</body>
</html>
I can't understand why this is not working.
Thanks,
Ranjan Kumar
August 11th, 2003, 02:52 PM
-
your first function is missing an end curly bracket
August 11th, 2003, 02:58 PM
-
Javascript - Error
I did catch that... but my alert statement is not returning anything.... I don't think it is getting executed at all....
Thanks,
Ranjan Kumar
August 11th, 2003, 03:37 PM
-
Code:
<select name="prod_access_area_frm_slc" onChange="document.frm_cat_lst.submit()">
As soon as you select an option from the selectbox, the form is submitted. The onsubmit handler defined in the form tag is NOT called.
And don't forget to add a default return value (return false) to the functions.
Hope this helps,
Jeroen
August 11th, 2003, 03:52 PM
-
Javascipt - Error
Hi,
Yes, thats what I also concluded. Anyways the thing which happens is that the next page is able to display the option which I selected on the previous page, but there is another dropdown box for Product Models which does not get filled.
So, I was wondering as to how this thing was being passed on to the server side script.
Thanks,
Ranjan.
Ranjan Kumar