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
Share on other sites

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! :(

Link to comment
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
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
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
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
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.