Auto Populate Form And Auto Submit With Url Parameters
I want to auto populate the below form with URL parameters for example using a URL like this: example.co.uk/example.php?acct=wirelesslogicde&pwd=jenkins I would also like it to
Solution 1:
<formaction="http://www.twg.com/logincheck.aspx"method="post"id="login"name="login"style="margin-bottom: 0;"><pclass="readmore"style="margin-bottom: 0;"><inputname="module"id="module"type="hidden"value="HL"/><inputname="page"id="page"type="hidden"value="account.aspx"/><strong>Account:</strong><br /><inputname="acct"id="acct"class="contact input"value="<?=$_GET['acct']?>"size="12"maxlength="16"/><br /><strong>Password:</strong><br /><inputtype="password"name="pwd"id="pwd"class="contact input"value="<?=$_GET['pwd']?>"size="12"maxlength="16"/><br /><br /><inputtype="submit"name="submit"id="submit"class="button"value="Login"/></p></form>
Use $_GET
to get the values from URL
.
For auto submit use, Make sure you have jquery plugin loaded before you use the following script. If you don't have JQuery added get it from JQuery and include the file like any other javascript
file in your <head>
section of HTML
document.
$(document).ready(function() {
$("#login").submit();
});
Solution 2:
you could do the autosubmit by using jQuery
$('#some_form_id').onLoad(function(){
$.Post('form_target',{parameters:values});
});
and for the populate you can add
<inputname="acct"id="acct"class="contact input"size="12"maxlength="16"value="<?phpecho$_REQUEST['acc']; ?>"/><inputtype="password"name="pwd"id="pwd"class="contact input"size="12"maxlength="16"value="<?phpecho$_REQUEST['pwd']; ?>"/>
Solution 3:
You can do this either by php using for example:
<inputname="acct"id="acct"class="contact input"size="12"type="text"value=="<?phpecho$_GET['acct'];?>"maxlength="16"/>
or using javascript, which would be a bit more complex, look at the window.location.search to filter down querystrings..
ref: https://developer.mozilla.org/en-US/docs/DOM/window.location
Post a Comment for "Auto Populate Form And Auto Submit With Url Parameters"