Modernvox Posted November 16, 2009 Share Posted November 16, 2009 If I want to ask the user if there inquiry is for an interior or exterior job. Can i do this without showing all the form fields initially? Can I ask the question: interior or exterior? Then based on the answer display the appropriate form fields? Quote Link to comment https://forums.phpfreaks.com/topic/181765-solved-is-it-possible-to-show-a-specific-form-field-based-on-a-users-input/ Share on other sites More sharing options...
premiso Posted November 16, 2009 Share Posted November 16, 2009 You can do it using a drop down menu, or buttons etc. It is all possible. Just have an initial form say "Click interior or exterior" with two buttons, depending on what the user clicked show them the appropriate form. Quote Link to comment https://forums.phpfreaks.com/topic/181765-solved-is-it-possible-to-show-a-specific-form-field-based-on-a-users-input/#findComment-958627 Share on other sites More sharing options...
mattyvx Posted November 16, 2009 Share Posted November 16, 2009 you could re-direct to another form "interior" or "exterior" based on a drop down, hyperlink, option group etc etc.... or you could ask the user for the input as before but submit the form to itsself and use something like if(isset($interior)){ //show interior options} elseif(isset($exterior)){ //show exterior options} Quote Link to comment https://forums.phpfreaks.com/topic/181765-solved-is-it-possible-to-show-a-specific-form-field-based-on-a-users-input/#findComment-958632 Share on other sites More sharing options...
Modernvox Posted November 16, 2009 Author Share Posted November 16, 2009 Great, thanks guys! Please don't bite my head off, but (after a month) I am still having trouble with php syntax "God I wish it were as easy as C++" Anyhow what determines the proper syntax to use when grabbing values from a variable. I understand parenthesis is used to extract the value , but see the following code I am checking: It ignores the if statement: <html> <body> <?php if(isset($_POST['submit'])) { if ( $_post['rooms'] == "2") echo "great!"; } $stories = $_POST['stories']; $rooms = $_POST['rooms']; $sum=$stories + $rooms; echo($sum); ?> </body> </html> I am really that dumb or is this tricky? YOU CAN BE HONEST WITH ME Quote Link to comment https://forums.phpfreaks.com/topic/181765-solved-is-it-possible-to-show-a-specific-form-field-based-on-a-users-input/#findComment-958636 Share on other sites More sharing options...
mattyvx Posted November 16, 2009 Share Posted November 16, 2009 what is the code for your HTML form, remeber that your input submit button must be called name="submit" for it to work in the above code. Quote Link to comment https://forums.phpfreaks.com/topic/181765-solved-is-it-possible-to-show-a-specific-form-field-based-on-a-users-input/#findComment-958640 Share on other sites More sharing options...
Modernvox Posted November 16, 2009 Author Share Posted November 16, 2009 what is the code for your HTML form, remeber that your input submit button must be called name="submit" for it to work in the above code. <html> <body> <form action="getquote.php" method= "post"> Number of stories: <input type="text" name="stories" /> Number of rooms: <input type= "text" name= "rooms" /> <input type="submit" name="submit" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/181765-solved-is-it-possible-to-show-a-specific-form-field-based-on-a-users-input/#findComment-958644 Share on other sites More sharing options...
mattyvx Posted November 16, 2009 Share Posted November 16, 2009 <html> <body> <?php if(isset($_POST['submit'])) { if ( $_POST['rooms'] == "2") { echo "great!"; } } $stories = $_POST['stories']; $rooms = $_POST['rooms']; $sum=$stories + $rooms; echo($sum); ?> </body> </html> my bad i missed a few things in your PHP. first you need to open a "{" bracket for each if statement. second your $_POST should be in caps and not lower case. The above should work! Quote Link to comment https://forums.phpfreaks.com/topic/181765-solved-is-it-possible-to-show-a-specific-form-field-based-on-a-users-input/#findComment-958648 Share on other sites More sharing options...
Modernvox Posted November 16, 2009 Author Share Posted November 16, 2009 <html> <body> <?php if(isset($_POST['submit'])) { if ( $_POST['rooms'] == "2") { echo "great!"; } } $stories = $_POST['stories']; $rooms = $_POST['rooms']; $sum=$stories + $rooms; echo($sum); ?> </body> </html> my bad i missed a few things in your PHP. first you need to open a "{" bracket for each if statement. second your $_POST should be in caps and not lower case. The above should work! It Works...Thanks Man! (I hope your a Man Quote Link to comment https://forums.phpfreaks.com/topic/181765-solved-is-it-possible-to-show-a-specific-form-field-based-on-a-users-input/#findComment-958653 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.