javascript - Clear form that has been automatically filled in with PHP echo code -


i have created order form , have automatically filled in of fields current users information has been stored in database. however, realise people times want order somewhere new , may change details particular order. @ moment of form field code is:

<label>email :</label>     <input type="text" value="<?php echo $info[email]?>" name="email" id="email">  			

is there way me clear value of field when echoing value?

i know how clear form using javascript , reset() function on form button, clear values of fields user has entered not ones output php code. nudge in right direction appreciated :).

first: that's correct, can't php

then: neither pure javascript (except if loop through inputs , change value), javascript reset() 'reset' form values defaults , when define (in html) input tags 'value' string defining default value.

lastly, can either use ajax , fill inputs javascript (or use angular) or use jquery or write java script function iterate through input elements of form , change 'value' attributes empty string:

using jquery: jquery/javascript function clear fields of form or how reset (clear) form through javascript?

using javascript:

function resetform(frm_elements){ (i = 0; < frm_elements.length; i++) {     field_type = frm_elements[i].type.tolowercase();     switch (field_type)     {     case "text":     case "password":     case "textarea":     case "hidden":         frm_elements[i].value = "";         break;     case "radio":     case "checkbox":         if (frm_elements[i].checked)         {             frm_elements[i].checked = false;         }         break;     case "select-one":     case "select-multi":         frm_elements[i].selectedindex = -1;         break;     default:         break;     } } } 

sources: 1 & 2

hope helps, ;)


Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -