Add part of a URL to an input field

Hi there,

I have the following url:

http://www.webiste.com/directory/directory/page.html?name=john

What I would like to do is to add the “john” part to the following field, e.g

<input type="hidden" name="agent" value="john">

How would I do this using jQuery?

Thanks!

this field already contains “john”, so I’m not sure what you want to add.

The above was an example of how I would like the input to look. Basically I need to replace or append whatever is in the value attribute.

Must it be via jQuery?
It’s the sort of thing I would do server-side.

I would need it to be jQuery

// form is your form object. access it according to your HTML code
form.agent.value = location.search.split('=')[1];

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.