动态表行将变量传递给jQuery模态

时间:2012-12-14 05:50:57

标签: php jquery

我有一个通过PHP创建的动态表行,如下所示:

 while($carrier = mysql_fetch_array($selcomp)){
                $carrier1 = $carrier['carname'];
            }
            ?>
            <tr ><td><a class='activate_modal' name='<?php echo $leadlist['ID'];?>' href="#"><input id="soft-quote" type="button" value="Soft Quote" class="searchbutton" /></a></td></tr>
            <?
         }

我需要以某种方式传递

      name='<?php echo $leadlist['ID'];?>'

通过对话框打开

 $( "#dialog-form" ).dialog({
        autoOpen: false,
        height: 300,
        width: 350,
        modal: true,
        buttons: {
            "Complete Soft Quote": function() {
                var bValid = true;
                allFields.removeClass( "ui-state-error" );


                if ( bValid ) {
                          // call to some ajax.
                    $( this ).dialog( "close" );
                }
            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }
        },
        close: function() {
            allFields.val( "" ).removeClass( "ui-state-error" );
        }
    });

        $('.activate_modal').click(function(){

            var rowid = $(this).attr('name');

            $( "#dialog-form" ).dialog( "open" );

        });

要么是形式:

<div id="dialog-form" title="Create Soft Quote">
<p class="validateTips">All form fields are required.</p>

<form>
<fieldset>
    <label for="payroll">Payroll</label>
    <div id="yourelement"></div>
    <input type="text" name="name" id="name" class="text ui-widget-content ui-corner-all" />
    <label for="email">Email</label>
    <input type="text" name="email" id="email" value="" class="text ui-widget-content ui-corner-all" />
    <label for="taxid">Federal Tax ID</label>
    <input type="text" name="taxid" id="taxid" value="" class="text ui-widget-content ui-corner-all" />
</fieldset>
</form>

或直接使用jquery函数。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

试一试。

$('.activate_modal').click(function(){
   var rowid = $(this).attr('name');
   alert(rowid);
   $('#taxid').after('<input type="hidden" name="rowid" id="rowid" value="'+rowid+'" />');   
   $('#dialog-form').dialog('open');
});