Jump to content

Call to a web page based on Select statement


judikrd

Recommended Posts

Hi...I'm fairly new to PHP and don't understand why sometimes I have access to a $_POST variable, and sometimes not. Here's my specific question:

I'd like my web page to call another page after the user has chosen an item from a SELECT statement. Here's what I've got:

<form name="select" method="post">
<select name="groupChoice" id="groupChoice">
<?php for ($j=1; $j<=$i; $j++) {
echo '<option value =', $keyn[$j], '>', $selectGr[$j], '</option>';
} ?>
</select> <br>
<p><a href="combSelect.php?keyn=<?php echo $_POST['groupChoice'] ?>">Click here to buy </a>

But when a user clicks on the HREF link, there's a blank where the result of <?php echo $_POST['groupChoice'] ?> should be.

So I'm thinking that I need to use a Submit button for the $_POST variable to get a value, right? I tried using onclick="document.location = 'combSelect2.php?keyn=<?php echo $_POST['groupChoice'] ?>' " instead, but the page never went to a new page...

How can I send the user to the correct web page based on their choice in the Select?

Thanks so much for any insights you can give me!!
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.