Hi

in my sidebar i have block with a form where users add name of restaurant and when they cick Submit they are supposed to be redirected to a page where my webform is.

I need url like this /add-your-restaurant?key=value-from-text-field but im not sure how to pass that value in url with my form.

I have already %get[key] as default value for my Name field in webform.

This is my html form:

<form name="addres" id="addres" method="post" action="">
<span>
<input type="text" name="addresfield" class="resfield" value="Enter your Restaurant name"/>
</span>
<input type="button" class="btn"/>
</form>

Comments

alex.87’s picture

Title: Hot to pass value from form to url parameter » How to pass value from form to url parameter
quicksketch’s picture

Status: Active » Closed (won't fix)

If you've just hand-coded your form in your sidebar, I'd suggest using JavaScript to set the "action" property of your form when you click the submit button. Or just use JavaScript to set the window.location variable in the browser, which will do a redirect.

This question is generally not about Webform at all (at least you've figured out the part Webform is responsible for), so I'd encourage you to Google a script that will do this redirection for you. The Webform queue is for questions about Webform, not general coding questions.

knalstaaf’s picture

Issue summary: View changes

In case someone is interested in a Q&D way to do this, you can start from here:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Pass checkbox and radio values to URL</title>
  <script src="https://code.jquery.com/jquery-1.10.0.js"></script>
</head>
<body>
 
<form class="myform"> 
  <br />
  <input type="checkbox" name="check" value="check1" id="ch1">
  <label for="ch1">check1</label>
  <input type="checkbox" name="check" value="check2" id="ch2">
  <label for="ch2">check2</label> 
  <br />
  <input type="radio" name="radio" value="radio1" id="r1">
  <label for="r1">radio1</label>
  <input type="radio" name="radio" value="radio2" id="r2">
  <label for="r2">radio2</label>      
</form>
 
<script type="text/javascript">
  jQuery.noConflict();    
  function showValues() {
    var radios = jQuery('input[type=\'radio\']:checked').map(function() { return this.value; }).get().join(', ');  // feel free to use classes instead
    var checkboxes = jQuery('input[type=\'checkbox\']:checked').map(function() { return this.value; }).get().join(', ');   // feel free to use classes instead
      jQuery("a.mylink").attr("href", "node/1?chks="+checkboxes+"&rads="+radios);  
  }
  jQuery( "input[type='checkbox']" ).on( "click", showValues );
  jQuery( "input[type='radio']" ).on( "click", showValues );
     
  showValues();
    
</script>

<a href="node/1" class="mylink">Style me as a button</a>
    
</body>
</html>

(Source)