PDA

Click to See Complete Forum and Search --> : [RESOLVED] How to display data from 2 comboboxes


saraa
Mar 13th, 2007, 02:38 AM
hi all..i want to display fax data which choosed from 2 comboboxes.
one is branch and the other one is month.
The problem here i dont know how to bring a branch value when i choose month..
When i choose a month, it not brings a value of branch together..
Here is my codings.


<?
$month1=$_GET['Month'];
$branch_id=$_GET['branch'];

$queryB = mysql_query("SELECT * FROM branch WHERE code='$branch_id'");
$br=mysql_fetch_array($queryB);
$idB= $br['code'];
$nB=$br['name'];
?>

<form name="form1" id="form1" action="faxin2.php" method="get">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="3" >
<tr>
<td><div align="right"></div></td>
<td>&nbsp;</td>
<td align="center">Branch: <select name="branch" onChange="this.form.submit()">
<option value="">Select Branch</option>

<?
$sqlst = mysql_query("SELECT * FROM branch ORDER BY name");
while($branch = mysql_fetch_array($sqlst)){ ?>
<option value="<? echo $branch['code'] ?>"><? echo $branch['name'] ?>
</option>
<? } ?>
</select>&nbsp;<input type="text" name="branch_id" value="<? echo $branch_id;?>"><? echo $nB;?>

<select name="Month" id="Month" onChange="this.form.submit()">
<option value="">Select Month</option>
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>&nbsp;
<input type="submit" name="Submit" value="Show"></td>
</tr>
<tr>
<td colspan="5">&nbsp;&nbsp;</td>

</tr>
</table>
</form>


Please letme know how to solve this problem..thanks in advance

kows
Mar 13th, 2007, 10:38 AM
I'm a little confused as to what you want to do. from the javascript you're using on the <select> events, I assume you want to submit the form after picking a branch and month. to do this better, you should probably only have the "onchange" event on the month's <select>, not both. otherwise, whenever you pick a branch you will have the form submitted (and you will not have the chance to pick a month); and likewise, if you picked the month first, you wouldn't have a chance to pick the branch. you will probably need a bit more advanced javascript than this because you'll want to check to see if both <select>'s values are defined, and then you can submit. either way, I generally don't like self-submitting things like this, so I would advise that you just get rid of the javascript events you're using and stick to the "show" button that you have. as far as I can understand, this thing where when you pick one it automatically submits is your problem -- because it automatically submits the form before you have a chance to pick the other values.

saraa
Mar 13th, 2007, 11:13 AM
I'm a little confused as to what you want to do. from the javascript you're using on the <select> events, I assume you want to submit the form after picking a branch and month. to do this better, you should probably only have the "onchange" event on the month's <select>, not both. otherwise, whenever you pick a branch you will have the form submitted (and you will not have the chance to pick a month); and likewise, if you picked the month first, you wouldn't have a chance to pick the branch. you will probably need a bit more advanced javascript than this because you'll want to check to see if both <select>'s values are defined, and then you can submit. either way, I generally don't like self-submitting things like this, so I would advise that you just get rid of the javascript events you're using and stick to the "show" button that you have. as far as I can understand, this thing where when you pick one it automatically submits is your problem -- because it automatically submits the form before you have a chance to pick the other values.Thanks a lot Mr.kow..i got it now