|
-
Mar 13th, 2007, 02:38 AM
#1
Thread Starter
Junior Member
[RESOLVED] How to display data from 2 comboboxes
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.
PHP Code:
<?
$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> </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> <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>
<input type="submit" name="Submit" value="Show"></td>
</tr>
<tr>
<td colspan="5"> </td>
</tr>
</table>
</form>
Please letme know how to solve this problem..thanks in advance
-
Mar 13th, 2007, 10:38 AM
#2
Re: How to display data from 2 comboboxes
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.
-
Mar 13th, 2007, 11:13 AM
#3
Thread Starter
Junior Member
Re: How to display data from 2 comboboxes
 Originally Posted by kows
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|