caramoan tour package

caramoan tour package

Author Topic: Get Values in jQuery  (Read 174 times)

Offline mini_mouse ^_^

  • Size C Battery
  • *****
  • Posts: 244
  • Pogi/Ganda Points: 7
  • Gender: Female
  • he's keeping it up, I should take pride :)
Get Values in jQuery
« on: May 07, 2012, 01:56:24 PM »
button Save in html
Code: [Select]
<input  id = "btnSave"  type="submit" value="SAVE" class="button" style="width:72px"  />

div enclosing the checkboxList
Code: [Select]

  <div id="FamilyPlanningMethod" style="margin-left:75px;">  
      <table class="newRec" cellspacing="2px" cellpadding="2px" >      
        @{
               int i = 0;
               int len = 18;        }
            @for (int x = 0; x < len; x++)
            {              
                <tr>
                        @for (int col = 0; col < 3; col++)
                        {
                        <td width="250px" >
                        @{
                            string y = Convert.ToString(ViewBag.FamilyPlanningMethods[i].FamilyPlanningMethodId);
                                @Html.CheckBox(y)    
                                @:&nbsp
                                @ViewBag.FamilyPlanningMethods[i].FamilyPlanningMethod1    
                                <br />  
                           i++;
                            }                              
                        </td>                          
                        }
                </tr>
            }                        
       </table>  
    </div>  
checkbox is created using html Helper in MVC3 C# Ravor Engine View


here's how to code the click event of a button in jQuery
Code: [Select]
$("#btnTest").click(function () {
//code here
        });


sample code to get the names of the selected checkboxes from checkbox list
Code: [Select]
$("#btnTest").click(function () {
        var selected = [];
  //FamilyPlanningMethod is the id of div enclosing the checkboxlist
        $('#FamilyPlanningMethod input:checked').each(function () {
            selected.push(this.name);
            
        });
        alert(selected);
        return false;
    });

...I'm thankful each and every day, coz I found you...

Philippine Electronics Forum

Get Values in jQuery
« on: May 07, 2012, 01:56:24 PM »

Offline mini_mouse ^_^

  • Size C Battery
  • *****
  • Posts: 244
  • Pogi/Ganda Points: 7
  • Gender: Female
  • he's keeping it up, I should take pride :)
Re: Get Values in jQuery
« Reply #1 on: May 07, 2012, 02:07:08 PM »
Code in getting the text of the selected value in dropdownlist

Code: [Select]
var source = $("#SourceOfIncomeId option:selected").text(); //SourceIncomeId is the id of the dropdown
...I'm thankful each and every day, coz I found you...

Philippine Electronics Forum

Re: Get Values in jQuery
« Reply #1 on: May 07, 2012, 02:07:08 PM »

 

Privacy Policy

Contact Us: elabph@yahoo.com