我正在尝试创建用户控件,现在1个页面可以有2个用户控件,生成控件的php方法是
public function GenerateControl($control_name)
{
echo "<input type='text' id='".$control_name."' name='".$control_name."' value='' size='80' readonly/> ";
echo "<button width='20' height='20' onclick='ShowClientList()' style='padding: 0;'>...</button>";
echo "<div id='client_select_popup' class='popup' style='display:none;'>
<div id='client-grid' align='center'></div>
<input style='width:60px;width:60px;margin-top: 4px;' type='submit' value='Select' onclick='ChooseClient(\"$control_name\")' />
<input style='width:60px;width:60px;margin-top: 4px;' type='submit' value='Cancel' onclick='CancelChooseClient()' />
</div>";
}
现在,当我调用ChooseClient函数并尝试设置值时,它总是只得到第一个控件,而不是第二个控件。
function ChooseClient( edit_client)
{
var sm = clientGrid.getSelectionModel(),
row_arr = sm.getSelection(),
row_obj, id, name;
var clienttype = $('#clienttype').val();
if( clienttype == 1)
{
if ( row_arr[0] )
{
row_obj = row_arr[0],
id = row_obj.get( 'affiliate_id' ),
name = id + ' - ' + row_obj.get( 'affiliate_name' );
$('#'+edit_client).val(name);
}
else
{
alert( 'Select Affiliate at first' );
}
}
所以$(&#39;#&#39; + edit_client).val(name);始终设置在第一个控件中,而不设置在第二个控件上。任何帮助将不胜感激。