I want to check the URL for a parameter. If this parameter exists, I want to pass it into an input.
The URL is eg. www.xyz.com/?userid=1234
The goal should be:
- Check if URL contains parameter "userid="
- If yes, set the value as input of a value
My problem is, that I don't know, how to grab the value of the parameter. In my opinion it must be something like "take everything after "userid=" up to the end or an "&" (as possible beginn of new value)".
I think I would do with:
<input type="hidden" name="userid" type="text" value="" />
if(window.location.href.indexOf('userid=') > -1) { ... }
$('input[name=userid]').val('...');
In the end, the input should be have the value "1234" in my example.