Jump to content

[SOLVED] dropdown menus and 'if'


mcas

Recommended Posts

I'm trying for 2 days now to create a simple calculator that will display different units(factors) based on selections chosen from a dropdown menu....

 

so, if a user chooses option "a" from the dropdown...the unit factor will be displayed on the next line next to the input box...

and so on if they choose option "b"...

I've tried unsuccessfully $get_mdb=mysql_query("SELECT * FROM mnamedb WHERE unit='$green[0]' ORDER BY id ASC",$link ) or die(mysql_error()); and similar codes...

 

by the way, is there something similar to frontpage for html testing to be found anywhere for php code and display?

Link to comment
Share on other sites

if ($_POST[menu]==1) $unit1="selected"; echo'<tr><td

align"left">yes</td>';

 

if ($_POST[menu]==2) $unit2="selected";  echo'<tr><td align"left">no</td>';                                               

echo'<td><input class="inputp" name="'.$m_num.'" type="text" size="5" maxlength="5" value="'.$_POST[$m_num].'"></td></tr>';

 

oops...posted the $get_ instead of where I'm lost...I've tried 'else' in between the 'if' statements and that doesn't work....can someone tell me what I'm missing? In case you cant tell I am a bit of a n00b without my frontapge to show me how it looks and acts..lol

 

Thanks, lostincode (lol)

Link to comment
Share on other sites

well i dont like java script so i came up with a way to do that with php but it requires for the form to submit over and over again until the last submit bottom is click

 

on your select menu use the onchange="submit();"

 

and set the variable on the top page so when it's submit you get the value so $value next just echo it next to the selection 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.