问题描述:

I have a form.php which adds username selected from dropdown select, and user payments received into database. After inserting values by going to add_form.php, it comes back to form.php. I have sent the username from add_form.php to form.php by using below code

$result=mysql_query($sql);

if($result==1){

echo '<script language="javascript">';

echo 'alert("Payment added successfully");';

echo 'window.open("form.php?name='.$name.'", "_self");';

echo '</script>';

}

Now problem is that, how can I use this get parameter to select the passed value into dropdown automatically? I want the end user of the application to select a name once and add multiple payments, i.e., selected name should be there even after payment is added into db

网友答案:

I am not sure what you want but if filling up the select with options dynamically (with some js variables) is what you want then you can try something like.

$("#id_something").empty();
$("#id_something").append('<option selected="selected" value='+somejsvariable+'>'+someotherjsvariable+'</option>'); 

Hope it helps.

相关阅读:
Top