form submission donot take value of dynamically added option to dropdown list

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • godkrishna
    New Member
    • Sep 2008
    • 2

    form submission donot take value of dynamically added option to dropdown list

    Hi Guys.. I am new to javascript.. pls bare with me :)

    In my form, i have a table with two columns. first column has checkboxes and second has dropdown lists.

    On check of each check box.. certain 'options' are addded/removed from its corresponding dropdown list.

    My problem is, after adding/removing the 'options' dynamically, if I select the newly added option and submit the form, the corresponding value for the newly added option is actually not getting submitted. The form is submitted with some other option in the list. In other terms, the form is not getting submitted with the correct value, if I select the newly added option.

    Could any of you help me please? (Sorry that I donot know any PHP or ajax..)
  • godkrishna
    New Member
    • Sep 2008
    • 2

    #2
    Since my code is too big, let me paste you some pieces of it!!

    Code:
     <form
          name="update_all_instance"
                            method="POST"
                            action="/pls/EOF/Eof_Manage_Liveupdate.call_for_lu">
      <br/><br/>
     
       <SCRIPT>
         var arr1 = new Array();
    
           function remove_checked_instance(ischkd, inst_id) {
             var y = "";
             var arr2 = new Array();
             var strng;
             if(ischkd) {
               for(i=0;i<update_all_instance.p_from_instance_id.length;i++) {
                  for(j=0;j<update_all_instance.p_from_instance_id(i).options.length;j++) {
                    if(update_all_instance.p_from_instance_id(i).options[j].value == inst_id) {
                       y = y+"|"+i;
                       arr2[0] = inst_id;
                       arr2[1] = update_all_instance.p_from_instance_id(i).options[j].text;
                       update_all_instance.p_from_instance_id(i).remove(j);
                    }
                  }
               }
               if(y == "") return;
               strng = arr2.join("|");
               strng = strng+y;
               arr1.push(strng);
             }
             else {
               for(k=0;k<arr1.length;k++) {
                 strng = arr1[k].substring(0,4);
                 if(strng == inst_id) {
                   arr2 = arr1[k].split("|");
                   for(j=2;j<arr2.length;j++) {
                     for(i=0;i<update_all_instance.p_from_instance_id.length;i++) {
                       if(arr2[j] == i) {
                         y = document.createElement('option');
                         y.value = inst_id;
                         y.text = arr2[1];
                         y.name = "p_from_instance_id";
                         update_all_instance.p_from_instance_id(i).add(y);
                       }
                     }
                   }
                 }
               }
             }
           }
        </SCRIPT>
    Last edited by acoder; Sep 24 '08, 04:07 PM. Reason: Added [code] tags

    Comment

    • acoder
      Recognized Expert MVP
      • Nov 2006
      • 16032

      #3
      Show an example of a call to this function and some example HTML code.

      PS. please use code tags when posting code. Thanks.

      Comment

      Working...