RV Smart Site Blog

  • Published on Aug 15, 2012

    [sourcecode language="javascript" toolbar="true" htmlscript="true"] <script type="text/javascirpt" src="jquery.js"></script> <script> /** * @desc : value of id attribute of the form */ var form = $("#my-form"); var postData = ''; /** * @desc : This function is used to capture all the input * elements of the form and conver into query string . */ form.find('input ,select').each(function(){ // alert element name and value alert($(this).attr('name')+"="+ $(this).val()); postData += "&"+$(this).attr('name')+"="+ $(this).val(); }); // final output string alert("Query String ="+postData) ; </script> <form id="my-form"> Name : <input type='text' name='f_name' value='akki'> Address : <textarea name="address" cols="10" rows="4"></textarea> City : <select name="city"> <option>Mumbai</option> <option>Ahmedabad</option> <option>Bharuch</option> </select> </form> [/sourcecode]

0 Comments

 

© Copyright RV Smart Site 2024. All rights reserved.

Site secured by Comodo
Ride Digital