Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am new to jquery.
i have different controls like with same div tag textbox, checkbox, combobox etc., i have entered the values in these controls. using jquery i want to retrieve all the values from these controls and i want to store it to one object.

how to do. i am not getting
please help me .

thank you.
Posted
Comments
Sergey Alexandrovich Kryukov 8-Oct-12 21:29pm    
Not clear what's the problem. The answer is, well, using selectors. What did not work for you, why?
--SA

Hi,
If you are new to Jquery, then follow this site. It is very much helpful
http://www.w3schools.com/jquery/default.asp[^]
 
Share this answer
 
hi, consider you have these controls on your page:
HTML
<div id="myDiv">
       my div text
   </div>
   <input type="text" id="txt1" />
   <select id="ddl1">
       <option value="1">Test</option>
       <option value="2">Test 2</option>
   </select>
   <input type="checkbox" id="chk1" /><label for="chk1">Check Box</label>

   <input type="button" id="btn1" value="Get Value" onclick="GetValues();"/>

now on the button click call this javascript function to get all controls values like this:
JavaScript
<script type="text/javascript">
      function GetValues() {
          alert("my DIV content is " + $('#myDiv').html());
          alert("my text box value is " + $('#txt1').val());
          alert("my dropdownlist selected text is " + $('#ddl1 option:selected').text());
          alert("my checkbox is " + $('#chk1').attr('checked'));
      }
  </script>

Note that you have to add the jQuery reference in your Head tag
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900