Autofill input type="text" field from an external link -


i have link on 1 page looks this:

http://www.domain.com/sample-link#product_id 

and on other page (sample-link), have input field:

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

so, when click link first page, want open "sample-link" page, , autofill name field "product_id" text. ideas how can make this?

thanks in advance.

you'll have add tiny javascript snippet:

if (document.location.hash)     document.getelementbyid('testbox').value = decodeuricomponent(document.location.hash.substr(1)); 

for obvious reasons you'll have adjust id of text box. gets bit more complicated in case you'd pass more 1 value.

the call decodeuricomponent() optional, required in case you're passing characters spaces or non-alphanumerical stuff (just sure).


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -