How to change html controls with php as the user provides input? -


pretty new php , i'm wondering if there's way dynamically modify inputs available on html form using php without form data needing submitted. i'm making site calendar teacher , need make "duedate" input in form gray out user selects option "announcement."

<form action="calendaradd.php" method="post">     event name: <input name="eventname" type="text" autocomplete="off"/></br>     event type: <select>                     <option value="homework">homework</option>                     <option value="announcement">announcement</option>                 </select>     event date: <input type="date" name="eventdate"></br>     due date: <input type="date" name="duedate"></br></br>     <input name="submit" type="submit" value="submit"/> </form> 

many thanks. also, using select/option control correctly? options supposed use value attributes instead of name?

bind onchange select, , if value matches criterium, set input disabled:

using jquery make easier:

$('#select').on('change',function(){    var value = $(this).val();   if(value == 'announcement'){     $('#duedate').prop('disabled',true);   }   else{     $('#duedate').prop('disabled',false);   }      }); 

you need supply proper ids elements (you can them dom traversing, id faster , easier), though. also, select missing name attribute, need in order fetch value server-side.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -