Jump to content

I'm having trouble getting the values from my drop down boxes


adambedford

Recommended Posts

I've got a form where users begin their order. There are a few drop down boxes that cover additional aspects and the answers are either 'Y' or 'N'. The following page them reads these values using POST and does some calculations. Unfortunately, I'm not getting the values through and they are always showing as 'Y' regardless of the choice.

 

I didn't think I was doing anything wrong, but aparently something isn't quite right!

 

Here is my form:

 

  
<form id="form" name="form" method="post" action="handleorder.php">
<label for="Highlighted" class="label_left">Highlighted</label>
  <select name="Highlighted" size="1" id="Highlighted">
    <option value="Y">Yes</option>
    <option value="N">No</option>
  </select>
</div>
<div id="featuredwrapper">
  <label for="Featured" class="label_left">Featured</label>
  <select name="Featured" size="1" id="Featured">
    <option value="Y">Yes</option>
    <option value="N">No</option>
  </select>
</div>
<div id="homepagewrapper">
  <label for="Homepage" class="label_left">Homepage Featured</label>
  <select name="Homepage" size="1" id="Homepage">
    <option value="Y">Yes</option>
    <option value="N">No</option>
  </select>
</div>
<input type="submit" value="Submit" name="Submit" />
</form>

 

And here is the code on the following page that processes these values and stores them to local variables:

 

$highlighted = $_POST["Highlighted"];
$featured = $_POST["Featured"];
$homepage = $_POST["Homepage"];

 

Can anyone see why I'm not getting the proper value through? Also, I was considering using checkboxes but I wasn't sure how to process the array in PHP because I go on to do an If test on each of the 3 values. Would it be better to use checkboxes and if so, how would I then assign the value of the checkbox to a variable?

 

Thanks!

Link to comment
Share on other sites

OK I've figured out what the problem was. I had some If statements on the page and they were messing things up. Without them, the values from the drop downs are obtained fine.

 

Any idea why If statements might have been messing things up? And how can I make it so they work because I do need them.

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.