Author Topic: I'm having trouble getting the values from my drop down boxes  (Read 194 times)

0 Members and 1 Guest are viewing this topic.

Offline adambedfordTopic starter

  • Enthusiast
    • View Profile
I'm having trouble getting the values from my drop down boxes
« on: February 09, 2010, 04:38:29 PM »
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:

Code: [Select]
 
<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!

Offline bbaker

  • Enthusiast
    • View Profile
    • 4" Orange
Re: I'm having trouble getting the values from my drop down boxes
« Reply #1 on: February 09, 2010, 04:43:43 PM »
your code worked fine for me

Offline adambedfordTopic starter

  • Enthusiast
    • View Profile
Re: I'm having trouble getting the values from my drop down boxes
« Reply #2 on: February 09, 2010, 04:51:29 PM »
Thats worrying!

Any idea why I might be having trouble with it?

Offline adambedfordTopic starter

  • Enthusiast
    • View Profile
Re: I'm having trouble getting the values from my drop down boxes
« Reply #3 on: February 09, 2010, 05:57:38 PM »
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.

Offline ohdang888

  • Devotee
  • Gender: Male
  • Bom Chicka Wah Wah
    • View Profile
    • My faceboook app
Re: I'm having trouble getting the values from my drop down boxes
« Reply #4 on: February 09, 2010, 06:22:15 PM »
its most likely a variable used in the if statement....

isolate which if statement is the one not functioning like you need it to... and then echo its variables to see if the value is what it is supposed to be
mysql_query("your query") or die(mysql_error());
Use it.

Offline Hussam

  • Enthusiast
  • Gender: Male
  • Available for projects in PHP, Flash, and Cakephp.
    • View Profile
    • My Personal Page, as sexy and small as possible!
Re: I'm having trouble getting the values from my drop down boxes
« Reply #5 on: February 09, 2010, 08:07:11 PM »
can you just post the whole code so we can help ?
A lie can travel halfway around the world while the truth is putting on its shoes.

http://tutorialtip.com/About_Me/

Offline redarrow

  • Freak!
  • Gender: Male
  • PHP IS FOR LIFE!
    • View Profile
    • my free dating site (a blind php programmer!)
Re: I'm having trouble getting the values from my drop down boxes
« Reply #6 on: February 09, 2010, 08:32:02 PM »
Something like this you want i guess
Code: [Select]
<?php
if($highlighted =="Y"){
$highlighted="Yes")}else{
$highlighted="No"}
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.ath.cx/paypal_info/paypal1_info.inc

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.