开发者

dynamic created SELECT not passing correct VALUE to php

开发者 https://www.devze.com 2023-04-13 05:08 出处:网络
I have a select that is dynamically created. <select name=\"approve-<?php echo $leadID; ?>\" id=\"<?php echo $leadID; ?>\" class=\"approve\">

I have a select that is dynamically created.

<select name="approve-<?php echo $leadID; ?>" id="<?php echo $leadID; ?>" class="approve">
<option value="1">Yes</option>
<option value="2">No</option>
</select>

it is inside a php loop that retrieves records from a db. and a form that sends its content via $.post to a php file. for some reason even if I change the value of a SELECT, I receive back from the PHP file all 3 values the same. Any ideas?

JS:

var post = $('#开发者_如何学编程approveLead').serialize();    
$.post("db/approveleads.php", post, function(data) { 
alert(data);
return false;   
});

PHP:

echo '<br/>'.$_POST['approve-1'];
echo '<br/>'.$_POST['approve-2'];
echo '<br/>'.$_POST['approve-3'];


As far I can understand your $leadID returns 1,2,3.... etc.... If this is true you may find the following helpful....

<select name="approve-<?php echo $leadID; ?>" id="id_<?php echo $leadID; ?>" class="approve">
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号