I have multiple rows of data in an HTML table.  E.g., financial
transactions.  In each row I have an HTML dropdown SELECT with options
(user will select transaction tag).  I want the transactionID and
selected tagID to pass to an onchange event for that unique row.

The transactionID comes through for the unique row of data, but I
can't get the respective tagID to come through.  Any ideas?  Thanks.


$(".selectList").change(function(){

                        var formvalue = this.id;
                        var tagid = $(".selectList").val();

                        $.ajax({
                                type: "POST",
                                url: "tag_test/index.php",
                                data: "trans_id=" + formvalue + "&tag_id=" + 
tagid,
                                success: function(){
                                        $("#resultTable").before("<p 
class='new'>Added: <i>" + formvalue
+ tagid +"</i></p>");
                                        $(".selectList").val("");
                                }
                        });
                });

<select name="tag" class="selectList" id="<?php echo $transactions[$i]
['trans_id']; ?>">
                                                <option id="opt_tag" 
label="None" value="0">None</
option>
                                                <?php   for($j=0; 
$j<count($tags); $j++){
                                                                        // 
Current tag is "selected" in <option> tag
                                                                                
        $transTag = getTransactionTag($transactions[$i]
['trans_id']);
                                                                                
        if($transTag['tag_id'] == $tags[$j]['tag_id'])
                                                                                
                $selected = "SELECTED";
                                                                                
        else
                                                                                
                $selected = "";
                                                                ?>
                                                <option class="option" 
id="opt_tag" label="<?php echo
$tags[$j]['tag_name']; ?>" value="<?php echo $tags[$j]['tag_id']; ?>"
<?php echo $selected; ?>><?php echo $tags[$j]['tag_name']; ?></option>
                                                        <?php } ?>
                                                        </select>

Reply via email to