passing dynamic text box to jquery
i h开发者_运维知识库ave one php page where i generate textboxes from php and mysql table like
$sql="select * from product where pstatus=1";
$result=mysql_query($sql);
for($i=1;$i<=mysql_num_rows($result);$i++)
{
$row=mysql_fetch_array($result);
?>
<input class="text_field1" id="<?php echo $i ?>" name="q_<?php echo $row['pid']; ?>" type="text" />
<?Php
}
?>
what i want is, to get values of textboex in JQuery to to process like this....
$.ajax({
type: "POST",
url: "add_pro.php",
data: "cont_email="+ encodeURIComponent(cont_email)
+"&caccount="+ encodeURIComponent(caccount)
...............
where cont_email & caccount but in place of ........ i need to get values of these dynamic textboxs but total number of boxes depends upon database.
Thanks
I'm not sure how you want the data separated/formated but you could do something like:
var totalContent = '';
$('input .text_field1').each(function(){
totalContent += $(this).val() + '\n';
});
....
精彩评论