php - HTML <SELECT> on selected value the other module will be null -


i need this:

html

  <select class="nesty-input" style="max-width: 100%" name="what_about">   <option selected disabled hidden><?php echo $what_about[1]; ?></option>   <option value="0|-">-</option>   <option value="1|one">one</option>   <option value="2|two">two</option>   <option value="3|three">three</option>   </select>    <select class="nesty-input" style="max-width: 100%" name="im">   <option selected disabled hidden><?php echo $im[1]; ?></option>   <option value="0|-">-</option>   <option value="1|one">one</option>   <option value="2|two">two</option>   <option value="3|three">three</option>   </select> 

php

   $what_about = explode('|', $_post['what_about']);     $im = explode('|', $_post['im']); 

so, script: on page reload prints value (0=id, 1=text), because wanted in database archived id of selected item, problem when select value , reload page still remains, when select new 1 value of old null. known as: warning: undefined offset: 1.

you default selected element has no vlaue. you submit default values of $what_about , $im equals ['']. , somewhere in code later calling $what_about[1] or $im[1]

i recommend check if count($what_about) == 2 before call $what_about[1] , if count($im) == 2 before call $im[1]

or set value default select option

   <option selected disabled hidden value='|'><?php echo $im[1]; ?></option> 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -