Bradley99 Posted June 25, 2012 Share Posted June 25, 2012 So I have a PHP dropdown inside of a form, I want to code it so that if the second dropdown is picked as X then the third dropdown is auto picked. . So here's the code: <? $showevent = mysql_query("SELECT * FROM fights WHERE event='$viewevent' AND id NOT IN (SELECT fight_id FROM betting WHERE user_id='$user->id') ORDER by id ASC"); while($the=mysql_fetch_object($showevent)){ echo " <form action='' method='post'><tr><td class='profilerow'><input type=radio name=fighter_id value=$the->fighter1> $the->fighter1 <BR> <input type=radio name=fighter_id value=$the->fighter2> $the->fighter2 <BR> <input type=radio name=fighter_id value=1> Draw</td> <td class='profilerow'><select name=method><option value=KO>Knockout</option><option value=TKO>Technical Knockout</option><option value=DEC>Decision</option></select></td> <td class='profilerow'><select name=round><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option></select></td> <td class='profilerow'><select name=bonus><option value=Yes>Yes</option><option value=No>No</option></td> <input type='hidden' name='fight_id' value='$the->id'> <td class='profilerow'><input type='Submit' name='Submit' value='Pick' class='Submit' /> </td></form> </tr>"; } ?> So if I pick Method: Decision, then the Round dropdown is auto picked as the number of rounds in that fight from the rounds column in the fights table. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/264759-if-x-dropdown-is-picked-y-dropdown-is-automated/ Share on other sites More sharing options...
Mahngiel Posted June 25, 2012 Share Posted June 25, 2012 You'll need javascript. You can do it with AJAX or by id. see http://www.appelsiini.net/2010/jquery-chained-selects Quote Link to comment https://forums.phpfreaks.com/topic/264759-if-x-dropdown-is-picked-y-dropdown-is-automated/#findComment-1356922 Share on other sites More sharing options...
Bradley99 Posted June 25, 2012 Author Share Posted June 25, 2012 Thanks Quote Link to comment https://forums.phpfreaks.com/topic/264759-if-x-dropdown-is-picked-y-dropdown-is-automated/#findComment-1356932 Share on other sites More sharing options...
Bradley99 Posted June 28, 2012 Author Share Posted June 28, 2012 I've read up quit alot on this but can't seem to get it to work. Basically what I wan't to do with the following code: <? $showevent = mysql_query("SELECT * FROM fights WHERE event='$viewevent' AND id NOT IN (SELECT fight_id FROM betting WHERE user_id='$user->id') ORDER by id ASC"); while($the=mysql_fetch_object($showevent)){ if($user->bonusp == "0") { $msg = "<form action='' method='post'> <tr> <td colspan='100%' class='TableHeading'> <b>$the->fighter1 Vs $the->fighter2</b></td> </tr> <tr><td class='profilerow' colspan='100%'><img src='http://fightclub.mmamount.com/eng/fighters/$the->fighter1.png' alt='$the->fighter1'/><img src='http://fightclub.mmamount.com/eng/fighters/versus.png' alt='VS'/><img src='http://fightclub.mmamount.com/eng/fighters/$the->fighter2.png' alt='$the->fighter2'/></td></tr> <tr><td class='profilerow' colspan='2%' align='left'><input type=radio name=fighter_id value=$the->fighter1> $the->fighter1 </td><td class='profilerow' colspan='20%'> <input type=radio name=fighter_id value=1> Draw</td><td class='profilerow' colspan='78%'> <input type=radio name=fighter_id value=$the->fighter2> $the->fighter2 </td></tr> <tr><td class='profilerow' colspan='3%'>Method:</td> <td class='profilerow' colspan='97%'><select name=method><option value=KO>Knockout</option><option value=TKO>TKO</option><option value=SUB>Submission</option><option value=DEC>Decision</option></select></td></tr> <tr><td class='profilerow' colspan='3%'>Round:</td> <td class='profilerow' colspan='97%'><select name=round><option value=1>1</option><option value=2>2</option><option value=3>3</option><option value=4>4</option><option value=5>5</option></select></td></tr> <tr><td class='profilerow' colspan='3%'>Use Bonus?</td> <td class='profilerow' colspan='97%'>You have 0 Bonus points to use</td> <input type='hidden' name='bonus' value='0'></tr> <input type='hidden' name='fight_id' value='$the->id'> <tr><td class='profilerow' colspan='3%'>Finished?</td> <td class='profilerow' colspan='97%'><input type='Submit' name='Submit2' value='Pick' class='Submit' /> </td></form> </tr>"; Is code it so that if Decision is chosen from Method, Then the Round selection is automated (Unchangeable) to be whatever the amount of rounds in the fights is, which will be determined by the rounds column in my fights table. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/264759-if-x-dropdown-is-picked-y-dropdown-is-automated/#findComment-1357809 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.