I am trying to make a form be submitted if there is a trigger-parameter in the url. I so far added a code-snippet so automatically insert the parameter into the input field.
This is my current code, working perfectly when using the submit-button or Enter.
e.g => website.com/?lookup=value
<form method="post" name="formid" id="formid">
<?php $paraid = $_GET['lookup']; ?>
<input class="form-control" id="steamid" name="s" value="<?php echo $paraid; ?>" >
<input type="submit" id="invbtn" value="submit" />
</form>
<script>
$('#formid').submit(function() {
var id = $("#steamid").val().replace(/(?:https?\:)?\/\//i, '');
$.ajax({
type: "GET",
data: "s="+id,
url: 'steam.php',
beforeSend:function() {
$("#outputinfo").html("<center><img src='./assets/img/load.gif'></br></br>Wait...</center>");
},success: function(html) {
$("#outputinfo").html(html);
}
});
return false;
});
$(document).ready(function() {
var id = '<?php echo $_GET['s']; ?>';
if (id != null) {
$.ajax({
type: "GET",
data: "s="+id,
url: 'steam.php',
beforeSend:function() {
$("#outputinfo").html("<center><img src='./assets/img/load.gif'></br></br>Wait...</center>");
},success: function(html) {
$("#outputinfo").html(html);
}
});
}
return false;
});
</script>
Thanks in advance.. i hope you guys can help me out..