• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 806
  • Last Modified:

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

0
uk1900
Asked:
uk1900
  • 2
2 Solutions
 
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
 
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

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now