Note that there are some explanatory texts on larger screens.

plurals
  1. POPopulating a form using a url - multiple input types
    text
    copied!<p>Hi I'm trying to create a form that is pre-populated partially by form on the page before. This information is then posted to this new page which is then populated into the form on that page ready to be submitted to a database.</p> <p>I'm not a developer so I'm a little out of my depth here but this is what I've got so far..</p> <pre><code>&lt;?php $amount = $_GET['text-386']; $covermultiple = $_GET['radio-30']; $coverdobd = $_GET['d-o-b-d']; $coverdobm = $_GET['d-o-b-m']; $coverdoby = $_GET['d-o-b-y']; ?&gt; &lt;script type="text/javascript"&gt; document.getElementById('text-386').value = "&lt;?=$amount ?&gt;"; document.getElementByName('radio-30').checked = "checked"; document.getElementById('d-o-b-d').value = "&lt;?=$coverdobd ?&gt;"; document.getElementById('d-o-b-m').value = "&lt;?=$coverdobm ?&gt;"; document.getElementById('d-o-b-y').value = "&lt;?=$coverdoby ?&gt;"; &lt;/script&gt; </code></pre> <p>I'm getting the values out of the URL ok and can echo these out on the page fine, I've even managed to get text-386 appearing in the right place.. so thats one down! The problem is the other elements are a radio button with two options (radio-30) and a 3 select boxes with the days, months and year of a persons d-o-b. These two bits are populating.</p> <p>So in a nutshell..</p> <p>How can I use javascript (if that is the right way) alongside php to populate the radio and select tags on this form using information in the url? In a preferably straight forward way as possible?</p> <p>The url if it helps is..</p> <p><a href="http://localhost/datacapture/form-page/radio-30=Just+for+me&amp;text-386=%C2%A340%2C000&amp;d-o-b-d=11&amp;d-o-b-m=05&amp;d-o-b-y=1977" rel="nofollow">http://localhost/datacapture/form-page/radio-30=Just+for+me&amp;text-386=%C2%A340%2C000&amp;d-o-b-d=11&amp;d-o-b-m=05&amp;d-o-b-y=1977</a></p> <p>Thats obviously on the local build I'm using so that URL wouldn't work for you. I can see when googling lots of help posting information using radio/select etc but I want the opposite, how do you populate these from a url?</p> <p>Any help would be a lifesaver</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload