Request field fill in url

Asked

Viewed 345 times

3

Good afternoon...

I need your help. I have a page in html+php which is basically a field that queries a mysql database with ajax and returns the result as soon as the field is filled with the correct number (10 digits).

I wanted to make a request through the URL to already load the page with this field filled. For example... When I type google.com/? q=question Google opens with the field written "question"

How do I do it? I have to mark my field and set that "q"?

1 answer

2


I believe that’s what you’re looking for:

<input type="text" value="<?php echo $_GET['q'] ?>" />

Assuming the URL is: seusite.com/?q=string

The result with $_GET in the above example would be:

<input type="text" value="string" />

If the input for type="number", will only receive numbers from $_GET (ex., q=123456). If it is type="text", will receive any string (both of numbers as of letters).

UPDATING

Insert the script below into your source code. It will call the function if the $_GET return some value:

<?php if(isset($_GET['q'])){ ?>
<script>
window.onload = function() {
  setTimeout(function(){
    document.getElementsByClassName('inputid')[0].blur();
  },1);
};
</script>
<?php } ?>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.