Jump to content

Archived

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

Noctagon

(solved) if drop box

Recommended Posts

Hi All,

I am totally new to this stuff so thanks in advance for your patience :)

I am trying to run a simple if statement and it is not working as plan.  Perhaps someone could tell me why :)

I have a drop box weaved into my code as follows

[code]<select size="1" name="nomtacyn">
<option selected>No</option>
<option>Yes</option>
</select>[/code]

the form action is to run this

[code]<?php

  $nomtacyn = $_POST['nomtacyn'];

  $DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
?>
<html>
<head>
</head>
<body>

<?php

if ($nomtacyn = No) {
echo "Your have selected No";
}
else {
Echo "You have selected yes";
}

?>

</body>
</html>[/code]

Thanks :)

Share this post


Link to post
Share on other sites
Try recoding your form (which presumably uses the method="post") thus:

[code]<select size="1" name="nomtacyn">
<option value="No" selected="selected">No</option>
<option value="Yes">Yes</option>
</select>[/code]

Share this post


Link to post
Share on other sites
Thanks for the speedy reply.......doh.....I said to myself that double equals sign will never get me ;)

Cheers

Share this post


Link to post
Share on other sites
It would also be a good idea, as Andy suggested, to out values in your <option> tags, rather than just letting them take the value of the text.

Regards
Huggie

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.