html - Get selected option from the tag <select> in php to use on if -


i tried code:

<select name="selectedoption">     <option value="select">  select  </option>     <option value="option1">  option 1  </option>     <option value="option2">  option 2  </option> </select> <?php $selectedoption = $_post['selectedoption']; ?> <?php if($selectedoption == "option1") : ?>     <a href="#">this display if option 1 selected</a> <?php elseif($selectedoption == "option2") : ?>     <a href="#">this display if option 2 selected</a> <?php endif; ?> 

but errors when i'm testing on web. error apears "notice: undefined index: selectedoption in c:\wamp\www\vilaluz\index.php on line 40"

what trying option select , put text under if option 1 selected , different text under if option 2 selected, possible?

<form action="" method="post"> <select name="selectedoption">     <option value="select">  select  </option>     <option value="option1">  option 1  </option>     <option value="option2">  option 2  </option> </select> <input type="submit" value="post"/> </form> <?php if(isset($_post['selectedoption'])) : ?> <?php $selectedoption = $_post['selectedoption']; ?> <?php if($selectedoption == "option1") : ?>     <a href="#">this display if option 1 selected</a> <?php elseif($selectedoption == "option2") : ?>     <a href="#">this display if option 2 selected</a> <?php endif; ?> <?php endif; ?> 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -