onblur change form action

hi,
in the follow code I am trying to give the user a link of his search.
how can I copy what I type in the input and added to the value in form.action?

thx
<form action='?search=' method='post'>
   <input name='search' type='text'value='' onblur="copyToAction();">
   .....
</form>
<script>
function copyToAction(){
 //form.action.value = form.action.value + search.value
}
</script>

Open in new window

uk1900Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
<form action='?' method='get'>
   <input name='search' type='text' value='' onblur="copyToAction(this.value);">
   .....
</form>
<script>
function copyToAction(val){
 form.action = form.action + val
}
</script>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ZvonkoSystems architectCommented:
Check this:
<form action='?search=' method='post'>
   <input name='search' type='text'  value='' onblur="copyToAction(this);">
   .....
   <input type="submit" value="Search" >
</form>
<script>
function copyToAction(theField){
  var theForm = theField.form;
  theForm.action = "?search="+theField.value
}
</script>

Open in new window

0
ZvonkoSystems architectCommented:
By the way, you nead not to add the field value to the action because the value would be posted by submit.
0
uk1900Author Commented:
thank you for your help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.