Click here to Skip to main content
15,885,896 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
i have 100 textboxes and there is no id of the textbox...then how will i get the value of the particular textbox....please make me clear what to do......

thanks in advance
Posted
Updated 1-Mar-19 1:54am

Hi,
You can do this in two way.
First if you have all the textbox in a div then you get all the textbox value using children function like this,
JavaScript
function GetTextBoxValueOne() {
  $("#divAllTextBox").children("input:text").each(function () {
    alert($(this).val());
  });
}

Here we get all the textbox's value by its parents div Id.

Now another way is you can give a class name to those textboxes which value you need and get that control with class name like this,
JavaScript
function GetTextBoxValueTwo() {
  $(".text-box").each(function () {
    alert($(this).val());
  });
}

Here we are getting all the value with text-box class name.
Then you can call any of the function from document ready or button click.

I hope this will help.
Thanks :)
 
Share this answer
 
Comments
Monjurul Habib 16-Feb-13 13:20pm    
5+
Sk. Tajbir 16-Feb-13 13:53pm    
Thank You :)
hi, you can use the map function.

function getAllData(){
var allData = $("input[name='name_of_the_textbox']").map(function(){
return $(this).val();
}).get();
alert(allData);
}
 
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