Toy Posted February 26, 2011 Share Posted February 26, 2011 hey! I have a site where I want to use multiple issets at the same time, like if I have four buttons and four issets: if(isset($_POST['one'])) { echo '<div class="example_box">one</div>'; } if(isset($_POST['two'])) { echo '<div class="example_box">two</div>'; } if(isset($_POST['three'])) { echo '<div class="example_box">three</div>'; } if(isset($_POST['four'])) { echo '<div class="example_box">four</div>'; } but for some reason it seems like only one isset can be activate at a time, is there any way to work this out or something :s? I've tried some variants of elseif stuff and such, but yeah, I'm pretty new at this stuff Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/ Share on other sites More sharing options...
sasa Posted February 26, 2011 Share Posted February 26, 2011 you can't pres more then one button in time try some other type of input tags Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180097 Share on other sites More sharing options...
Toy Posted February 26, 2011 Author Share Posted February 26, 2011 oh, that's sad does anyone know any other ways of doing this if not using issets? it would be helpfull:) edit:oh, I didn't read your post properly, you mean like using text links or things like that?okay,thanks! would still need some help on how! Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180100 Share on other sites More sharing options...
Altrozero Posted February 26, 2011 Share Posted February 26, 2011 Hidden input fields could be used instead if you really wanted. you could go in your HTML <form method="post" action=""> <input type="hidden" value="value1" name="one" /> <input type="hidden" value="value2" name="two" /> <input type="hidden" value="value3" name="three" /> <input type="hidden" value="value4" name="four" /><input type="submit" value="submit" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180106 Share on other sites More sharing options...
Toy Posted February 26, 2011 Author Share Posted February 26, 2011 Hidden input fields could be used instead if you really wanted. you could go in your HTML <form method="post" action=""> <input type="hidden" value="value1" name="one" /> <input type="hidden" value="value2" name="two" /> <input type="hidden" value="value3" name="three" /> <input type="hidden" value="value4" name="four" /><input type="submit" value="submit" /> </form> wouldn't that just show all of the boxes :S? Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180108 Share on other sites More sharing options...
Altrozero Posted February 26, 2011 Share Posted February 26, 2011 I thought that is what you wanted? You haven't really explained what the output should look like? Depending on the users input. Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180110 Share on other sites More sharing options...
sasa Posted February 26, 2011 Share Posted February 26, 2011 use checkbox Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180119 Share on other sites More sharing options...
swharrell Posted February 26, 2011 Share Posted February 26, 2011 I assume you are wanting to display a specific div based on the users input. Try: <form name="form" action="<? echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" value="" name="input"> <input type="submit" name="submit" value="submit"> </form> <?php $num = $_POST['input']; switch ($num){ case 'one': echo '<div class="example_box">one</div>'; break; case 'two': echo '<div class="example_box">two</div>'; break; case 'three': echo '<div class="example_box">three</div>'; break; case 'four': echo '<div class="example_box">four</div>'; break; default: echo 'Default'; break; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180127 Share on other sites More sharing options...
Toy Posted February 26, 2011 Author Share Posted February 26, 2011 @sasa, I'd rather not as it would look totally wrong @swharrell, actually I'm not trying to do it on user input Look, there's simply four buttons, when I press button one, div 1 is going to appear, if I then click button three, div 3 is going to appear but div 1 should still be visible, get my drift? Is there any alternative to issets or whatever, because I'd love to not have to use checkboxes Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180135 Share on other sites More sharing options...
jcbones Posted February 26, 2011 Share Posted February 26, 2011 Use Javascript Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180145 Share on other sites More sharing options...
Altrozero Posted February 28, 2011 Share Posted February 28, 2011 Use javascript or save previous input to either a database or a users session/cookie. There are a few tutorials around to save data. Quote Link to comment https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180869 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.