Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript Array Creation Using A Web Html Form
    text
    copied!<p>I have a form like below I need to create an array for each radio button using JavaScript and I need to post to a PHP script using Ajax </p> <pre><code>&lt;form id="what" name="what" &gt; &lt;input type="radio" name="colors" id="red" value="red" /&gt;Red&lt;br /&gt; &lt;input type="radio" name="colors" id="blue" value="blue" /&gt;Blue&lt;br /&gt; &lt;input type="radio" name="colors" id="green" value="green" /&gt;Green &lt;input type="radio" name="animals" id="dog" value="dog" /&gt;Red&lt;br /&gt; &lt;input type="radio" name="animals" id="parrot" value="parrot" /&gt;Blue&lt;br /&gt; &lt;input type="radio" name="animals" id="horse" value="horse" /&gt;Green &lt;button type="button" &gt;send&lt;/button&gt; &lt;/form&gt; </code></pre> <p>My Ajax Posting Code</p> <pre><code>var data = 'username=' + username + '&amp;api_password=' + apipassword + '&amp;sender=' + sender + '&amp;to=' + owner + "," + mobile + '&amp;message=' + "Name : " + name +"%0d%0a"+ "Mobile No : " + mobile +"%0d%0a"+ "Address : " + street +" "+ area + " " + formlandmark +"%0d%0a"+ "Notes : " + notes + "%0d%0a" + "Order Id : " + randomnewnewnumber + "%0d%0a" + itemstosmsdata() + '&amp;priority=' + priority; var adminsubmit = 'name=' + name+'&amp;mobile='+ mobile +'&amp;adds='+ street +" "+ area + " " + formlandmark +'&amp;notes='+ notes+'&amp;orderid='+ randomnewnewnumber+'&amp;orders='+ itemstowebdata()+'&amp;status=opened'+'&amp;time='+time+'&amp;date='+ dates; $('.text').attr('disabled','true'); $('.loading').show(); $.ajax({ url: "http://something.some.com/appost.php?", // Your Sms Api Url type: "POST", data: data, cache: false, success: function (html) { alert("Order Placed"); if (html==1) { $('.form').fadeOut('slow'); $('.done').fadeIn('slow'); } } }); </code></pre> <p>The Data Sould Be Sent Like Below</p> <pre><code> radio[ { "radiobuttonename" =&gt; clicked value of the radio button},{ "radiobuttonename" =&gt; clicked value of the radio button}] </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload