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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -