Jump to content

If X dropdown is picked, Y dropdown is automated. . .


Bradley99

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.