Below is the javascript code which creates 4 textbox in 4 <td>
in a single on the click of checkbox. There are around 20 checkbox if all checkboxes are cliclked 20 <tr>
each with 4 checkboxes are formed. My question is how to get the values from these textboxes so that it can be inserted in the database.how to multiple insert these values one by one if multiple values are received.
str+="<tr id='unchk"+$(this).val()+"'>";
str+="<td class='tp' >";
str+="<input width='100%' type='type' value='"+$(this).val()+"' readonly />";
str+="</td>";
str+="<td class='tp'>";
str+="<select>";
str+="<option selected='selected' value='1'>Mr</option>";
str+="<option value='2'>Miss</option>";
str+="<option value='3'>Mrs</option>";
str+="</select>";
str+="</td>";
str+="<td class='tp'>";
str+="<input width='100%' id='cname"+$(this).val()+"' type='type' value='' onblur='getval("+$(this).val()+");'/>";
str+="</td>";
str+="<td class='tp' >";
str+="<input width='100%' type='type' value=''/>";
str+="</td>";
str+="<td class='tp' >";
str+="<input width='100%' type='radio' name='primary' onchange='getval("+$(this).val()+");' value=''/>";
str+="</td>";
str+="</tr>";
$('#pass').append(str);
here $('#pass') is the id of the div to which the entire rows are appende
Assign a name
to the text boxes being created and if you are using java, then you can get the values by:
request.getParameterValues("name_of_textboxes");
In Javascript, you can get the values by:
var textBoxValues = [];
$("input[name='name_of_textboxes']").each(function(){
textBoxValues.push($(this).val());
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.