javascript - How to add hyphen in between strings in url -


i have form in there 1 text field , ine submit button.on click of submit button,it goes next php page.the user can enter text in text field.the text field can contain n number of text string separated space.like user enters text name peter want text change my-name-is-peter in url. when user clicks on submit button.the url should become submit.php?search=my-name-is-peter

<form action="submit.php" method="get"> <input type="text" name="search" id="search"> <input type="submit" name="submit" value="submit"> </form> 

please guide on how add hyphen in strings in url.

<script>  var handler = function (element) {   element.form.search.value = element.form.search.value.replace(/ /g, '-'); };  </script>   <form action="" method="get">   <input type="text" name="search" id="search" />   <input type="submit" onclick="handler(this);" name="submit" value="submit" /> </form> 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -