Reputation: 75
I am having 3 textbox where the ids are
"ctl00_m_g_8b41d68e_7c2d_49c3_a4b5_316440ad77e1_SpListPicker_SelectionBox", "ctl00_m_g_9b41d68e_7c2d_49c3_a4b5_316440ad77e1_SpListPicker_SelectionBox" and "ctl00_m_g_8a41d68e_7c2d_49c3_a4b5_316440ad77e1_SpListPicker_SelectionBox".
Now the id which is getting generated dynamically, but the "SpListPicker_SelectionBox
" is constant.
Now I am having a requirement, onClick
of a button either of the 3 textbox will have the value, which is to be fetched. How can I get the value of textbox.
Any help is appreciated. Can we get the value on the like operator? where ID
like '%SpListPicker_SelectionBox
' ??
Upvotes: 0
Views: 269
Reputation: 73916
Try this:
var $inputs = $('input[id$="SpListPicker_SelectionBox"]')
Where $=
is the Attribute Ends With Selector
Then you can loop through each textbox and get the values like:
$inputs.each(function( index ) {
alert( index + ": " + $(this).val() );
});
Upvotes: 1
Reputation: 4431
you can write Javascript or jquery code runtime by using code while textboxs generated and use exact textbox id associate with jquery statement.
Upvotes: 0