#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    57
    Rep Power
    12

    Angry 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
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    147
    Rep Power
    12
    your first function is missing an end curly bracket
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    57
    Rep Power
    12

    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
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    May 2003
    Posts
    1,014
    Rep Power
    15
    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
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    57
    Rep Power
    12

    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

IMN logo majestic logo threadwatch logo seochat tools logo