Question: I have this text box here...

```
<input name="search" type="text" maxlength="512" id="search" class="searchField" autocomplete="off" title="" />

```

and I also have this submit

```
<input type="submit" name="btnSearch" value="Search" onclick="location.href='http://www.website.com/search/';" id="btnSearch" class="buttonSearch" />

```

what I am trying to do is add whatever is in the text box in my 

```
onclick="location.href='http://www.website.com/search/';"

```

so it would look like this..

```
onclick="location.href='http://www.website.com/search/what ever the user searches';"

```

how would I go about doing this, I have been googling my little heart out.

Answer: 
This should work:

```
onclick="location.href='http://www.website.com/search/'+document.getElementById('search').value;"

```

**But I wouldn't ever write that in one of my project as writing script directly on tags is a bad practice.**
You would be better off using the < script> tag for this task. Example:

```
<input name="search" type="text" maxlength="512" id="search" class="searchField" autocomplete="off" title="" />
...
<input type="submit" name="btnSearch" value="Search"  id="btnSearch" class="buttonSearch" />
<script type="text/javascript">
var button= document.getElementById('btnSearch');
button.onclick= function(){
    var text= document.getElementById('search').value;
    location.href='http://www.website.com/search/'+text;
}
</script>

```

However, you should try to 'clean' a little the text from the textbox so when you append it to the url you get a valid url. You should trim the text, then search for special characters and escape them, etc.