Results 1 to 2 of 2

Thread: Simple form issue

  1. #1
    Join Date
    Jan 2010
    Posts
    5
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Smile Simple form issue

    1) Script Title: Dynamic Ajax Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...jaxcontent.htm

    3) Describe problem:

    I was kindly provided with a modification for this script a while ago, specifically to be able to submit form data via a <select> drop-down list:

    Code:
    <form method="post" onsubmit="ajaxpage('submit.php?id=$ID&FORM1='+this.elements.FORM1.value+'&FORM2='+this.elements.FORM2.value,'$ID');return false;">
    
    <select name="FORM1" size="3">
    <option value="Value-1">Value-1</option>
    <option value="Value-2">Value-2</option>
    <option value="Value-3">Value-3</option>
    </select>
    
    <select name="FORM2" size="3">
    
    <option value="Value-4">Value-4</option>
    <option value="Value-5">Value-5</option>
    <option value="Value-6">Value-6</option>
    </select>
    
    <input type="submit" value="submit" name="submit">
    
    </form>
    Everything still works fine, I just now need to be able to do the exact same thing with multiple checkboxes, I've tried a variety of approaches but none have worked.

    Essentially something like this:

    Code:
    <form method="post" onsubmit="ajaxpage('submit.php?id=$ID&FORM1='+this.elements.FORM1.value+'&FORM2='+this.elements.FORM2.value,'$ID');return false;">
    
    <input type="checkbox" name="FORM1[]" value="Value-1" />Value-1<br />
    <input type="checkbox" name="FORM1[]" value="Value-2" />Value-2<br />
    <input type="checkbox" name="FORM1[]" value="Value-3" />Value-3<br />
    
    <input type="checkbox" name="FORM2[]" value="Value-4" />Value-4
    <input type="checkbox" name="FORM2[]" value="Value-5" />Value-5
    <input type="checkbox" name="FORM2[]" value="Value-6" />Value-6
    Any ideas? Thanks.

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    
    <head>
      <title></title>
    <script type="text/javascript">
    /*<![CDATA[*/
    /*]]>*/
    
    function Inputs(frm){
     var els=frm.elements,v1=false,v2=false,z0=0;
     for (;z0<els.length;z0++){
      if (els[z0].name=='FORM1[]'&&els[z0].checked){
       v1=els[z0].value;
      }
      if (els[z0].name=='FORM2[]'&&els[z0].checked){
       v2=els[z0].value;
      }
     }
     if (v1&&v2){
      alert('submit.php?id=$ID&FORM1='+v1+'&FORM2='+v2)
    //  ajaxpage('submit.php?id=$ID&FORM1='+v1+'&FORM2='+v2,'$ID');
     }
    }
    
    
    </script></head>
    
    <body>
    <form method="post" onsubmit="Inputs(this);return false;">
    
    <input type="radio" name="FORM1[]" value="Value-1" />Value-1<br />
    <input type="radio" name="FORM1[]" value="Value-2" />Value-2<br />
    <input type="radio" name="FORM1[]" value="Value-3" />Value-3<br />
    
    <input type="radio" name="FORM2[]" value="Value-4" />Value-4
    <input type="radio" name="FORM2[]" value="Value-5" />Value-5
    <input type="radio" name="FORM2[]" value="Value-6" />Value-6
    <input type="submit" name="" value="Submit" />
    </form>
    </body>
    
    </html>
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •