Jump to content

quick question:)


Toy

Recommended Posts

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 :)

Link to comment
https://forums.phpfreaks.com/topic/228949-quick-question/
Share on other sites

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>

Link to comment
https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180106
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180108
Share on other sites

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;
}								
?>

 

Link to comment
https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180127
Share on other sites

@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

Link to comment
https://forums.phpfreaks.com/topic/228949-quick-question/#findComment-1180135
Share on other sites

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.