Jump to content


This topic is now archived and is closed to further replies.


Call to a web page based on Select statement

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

Share this post

Link to post
Share on other sites


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.