adambedford Posted February 9, 2010 Share Posted February 9, 2010 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! Quote Link to comment https://forums.phpfreaks.com/topic/191543-im-having-trouble-getting-the-values-from-my-drop-down-boxes/ Share on other sites More sharing options...
bbaker Posted February 9, 2010 Share Posted February 9, 2010 your code worked fine for me Quote Link to comment https://forums.phpfreaks.com/topic/191543-im-having-trouble-getting-the-values-from-my-drop-down-boxes/#findComment-1009712 Share on other sites More sharing options...
adambedford Posted February 9, 2010 Author Share Posted February 9, 2010 Thats worrying! Any idea why I might be having trouble with it? Quote Link to comment https://forums.phpfreaks.com/topic/191543-im-having-trouble-getting-the-values-from-my-drop-down-boxes/#findComment-1009717 Share on other sites More sharing options...
adambedford Posted February 9, 2010 Author Share Posted February 9, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/191543-im-having-trouble-getting-the-values-from-my-drop-down-boxes/#findComment-1009756 Share on other sites More sharing options...
ohdang888 Posted February 9, 2010 Share Posted February 9, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/191543-im-having-trouble-getting-the-values-from-my-drop-down-boxes/#findComment-1009769 Share on other sites More sharing options...
Hussam Posted February 10, 2010 Share Posted February 10, 2010 can you just post the whole code so we can help ? Quote Link to comment https://forums.phpfreaks.com/topic/191543-im-having-trouble-getting-the-values-from-my-drop-down-boxes/#findComment-1009811 Share on other sites More sharing options...
redarrow Posted February 10, 2010 Share Posted February 10, 2010 Something like this you want i guess <?php if($highlighted =="Y"){ $highlighted="Yes")}else{ $highlighted="No"} ?> Quote Link to comment https://forums.phpfreaks.com/topic/191543-im-having-trouble-getting-the-values-from-my-drop-down-boxes/#findComment-1009816 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.