ifis Posted January 10, 2008 Share Posted January 10, 2008 I am working on a form that depending on what a person selects form a dropdown menu, more information might or might not be required. If more info is required I have an IF statement, but is no information is required, I just have a submit button. Is there an elegant way to post a message, like "No furthur info is needed" without having to make IFs for every selection from the dropdown menu? Here is the current: <?PHP $lic=$_POST['lic'] if ('lic'== yyyy) {echo "<input type='text' name='moreinfoy' id='moreinfoy' /> </label>" } if ('lic'== xxxx) {echo "<input type='text' name='moreinfox' id='moreinfox' /> </label>" } echo " <input type='submit' name='Submit' id='Submit' value='Submit' /> </label> </p> </form>"; ?> THanks Link to comment https://forums.phpfreaks.com/topic/85423-solved-dealing-with-multiple-ifs-in-an-if-else-statement/ Share on other sites More sharing options...
rhodesa Posted January 10, 2008 Share Posted January 10, 2008 you want a switch statement Link to comment https://forums.phpfreaks.com/topic/85423-solved-dealing-with-multiple-ifs-in-an-if-else-statement/#findComment-435848 Share on other sites More sharing options...
ifis Posted January 10, 2008 Author Share Posted January 10, 2008 Cool so it would go something like switch('lic') { case yyyy: echo" we need more info"; break; case xxxx: echo" we need more info"; break; default: echo "no more info needed"; } I'll plug it in, thanks, looks like exactly what I was looking for! Link to comment https://forums.phpfreaks.com/topic/85423-solved-dealing-with-multiple-ifs-in-an-if-else-statement/#findComment-435852 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.