I am trying to make a user control, now 1 page can have 2 user controls, The php method that generates control is
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>";
}
Now when I call ChooseClient function and try to set the value, it always gets only the first control and doesn't get the second one.
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' );
}
}
so $('#'+edit_client).val(name); always sets in the first control and doesn't set on the second one. Any help would be greatly appreciated.