html - Pre-populating HTML5 form with URL variable -


i have following html code:

<section id="two" class="wrapper alt style2"> <section dir="rtl">     <center>         <h1> מילוי פרטים אישיים לתעודת אחריות</h1>     </center>     <br>     <!-->     <form method="post" action="#">         <!-->         <form id="frmcontainer6" method="post" enctype="application/x-www-form-urlencoded" action="https://web.mxradon.com/t/formtracker.aspx" onsubmit="return lpcontentgrabber('frmcontainer6');">             <!-->             <form action="mailto:graphics@emka.co.il" method="post">                 <!-->                 <div class="row uniform">                     <div class="6u 12u$(xsmall)">                         <input type="text" id="efullname" name="efullname" maxlength="100" value="" placeholder="שם מלא" autocomplete="off" />                     </div>                     <div class="6u$ 12u$(xsmall)">                         <input type="email" name="email" id="email" value="" placeholder="email" required />                     </div>                     <div class="6u 12u$(xsmall)">                         <input type="text" name="phonenu" id="phonenu" value="" placeholder="מספר טלפון" required />                     </div>                     <div class="6u$ 12u$(xsmall)">                         <input type="text" name="cadress" id="cadress" value="" placeholder="כתובת" required />                     </div>                     <br>                     <div class="6u 12u$(xsmall)">                         <input type="text" id="pmodel" name="pmodel" maxlength="100" value="" autocomplete="off">                     </div>                     <div class="6u$ 12u$(xsmall)">                         <input type="text" name="serialnu" value="sn12-8486-ef19-8541" id="serialnu" readonly/>                     </div>                     <div class="12u$">                         <textarea name="message" id="message" placeholder="הערות נוספות" rows="6"></textarea>                     </div>                     <div class="image center">                         <input type="checkbox" id="demo-copy" name="demo-copy">                         <label for="demo-copy">סמן לקבלת מבצעים והנחות למייל</label>                     </div>                     <div class="12u$">                         <ul class="actions">                             <center>                                 <li>                                     <input type="submit" value="שלח טופס" class="special" />                                 </li>                                 <li>                                     <button type="reset" value="reset">נקה טופס</button>                                 </li>                             </center>                         </ul>                     </div>                 </div>             </form> </section> 

i'm trying pre-fill pmodel value url using somthing

www.ee.com?pmodel=123456 

but doesn't work.

what doing wrong?

you're inserting url parameter. in order pre-fill value need retrieve url , insert value pmodel element.

you can either on server side (for example php, java, depends on server) or on client's side javascript after page loads.

for example (javascript) insert script on end of page:

<script type="text/javascript">     //get url parameters     var parameters = window.location.search.substring(1).split("&");     var splitparam, value;     //cycle through them , find correct 1     for(var i=0; i<parameters.length; i++){         splitparam = parameters[i].split("=");         if(splitparam[0]=="pmodel"){             //get value             value = splitparam[1];             break;         }     }     if(value){         //set input value         document.getelementbyid("pmodel").value = value;     } </script> 

example filling: jsfiddle


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -