title: How to pass the radio button value which is clicked to controller?
body: <p>I am using Spring MVC controller.</p>
  
  <p>Below is my JSP code in which it will show three radio button. One is <code>Insert</code>, second radio button is <code>Update</code> and third radio button is <code>Delete</code>.</p>
  
  <p>Once I click <code>Insert</code> radio button, it show two text box next to Insert radio button, and same thing with other two radio button.</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function doDisplay(radio) {
          switch (radio.value) {
          case "Insert":
              document.getElementById("inserts").style.display = "inline";
              document.getElementById("updates").style.display = "none";
              document.getElementById("delete").style.display = "none";
              break;
          case "Update":
              document.getElementById("inserts").style.display = "none";
              document.getElementById("updates").style.display = "inline";
              document.getElementById("delete").style.display = "none";
              break;
          case "Delete":
              document.getElementById("inserts").style.display = "none";
              document.getElementById("updates").style.display = "none";
              document.getElementById("delete").style.display = "inline";
              break;
          }
      }
  &lt;/script&gt;
  &lt;body&gt;
      &lt;form method="post" action="testOperation"&gt;
  
          &lt;input type="radio" name="tt" value="Insert"
              onclick="doDisplay(this);" /&gt; Insert &lt;input type="hidden" name="name" value="insert"&gt;&lt;span id="inserts"
              style="display: none"&gt; &lt;label for="Node"&gt; Node &lt;/label&gt; &lt;input
              type="text" name="node" size="20" /&gt; &lt;label for="Data"&gt; Data &lt;/label&gt;
              &lt;input type="text" name="data" size="100" /&gt;
  
          &lt;/span&gt; &lt;br /&gt; &lt;input type="radio" name="tt" value="Update"
              onclick="doDisplay(this);" /&gt; Update &lt;input type="hidden" name="name" value="update"&gt; &lt;span id="updates"
              style="display: none"&gt; &lt;label for="Node"&gt; Node &lt;/label&gt; &lt;input
              type="text" name="node" size="20" /&gt; &lt;label for="Data"&gt; Data &lt;/label&gt;
              &lt;input type="text" name="data" size="100"/&gt;
  
          &lt;/span&gt; &lt;br /&gt; &lt;input type="radio" name="tt" value="Delete"
              onclick="doDisplay(this);" /&gt; Delete &lt;input type="hidden" name="name" value="delete"&gt;&lt;span id="delete"
              style="display: none"&gt; &lt;label for="Node"&gt; Node &lt;/label&gt; &lt;input
              type="text" name="node" size="20" /&gt; &lt;label for="Data"&gt; Data &lt;/label&gt;
              &lt;input type="text" name="data" size="100"/&gt;
  
          &lt;/span&gt; &lt;br /&gt;
          &lt;input type="submit"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>Now what I am trying to do is as soon as I click on <code>Insert</code> radio button, it will show me two textbox next to <code>Insert</code> radio button. And after putting some values inside those two text box, I press submit button on the form. And then it goes to <code>testOperations</code> method in which <code>name</code> field has these many things - </p>
  
  <p><code>insert,update,delete</code></p>
  
  <p>How can I force it to have only one field which I am clicking only? Meaing if I am clickign insert radio button, then name variable should have insert value? Below is my method - </p>
  
  <pre><code>   @RequestMapping(value = "testOperation", method = RequestMethod.GET)
      public Map&lt;String, String&gt; testOperation() {
          final Map&lt;String, String&gt; model = new LinkedHashMap&lt;String, String&gt;();
          return model;
      }
  
      @RequestMapping(value = "testOperation", method = RequestMethod.POST)
      public Map&lt;String, String&gt; testOperations(@RequestParam String name, 
                                                @RequestParam String node, 
                                                @RequestParam String data) {
          final Map&lt;String, String&gt; model = new LinkedHashMap&lt;String, String&gt;();
  
          System.out.println(name);
          System.out.println(node);
          System.out.println(data);
  
          return model;
      }
  </code></pre>
  
  <p>Meaning, Suppose I click Insert radio button and type <code>Hello</code> in the first text and <code>World</code> in the second text box, then I will hit the submit button, and after that I should see <code>insert</code> value in the <code>name</code>  variable and <code>hello</code> value in the <code>node</code> variable and <code>world</code> value in the <code>data</code> variable.</p>
  
  <p>And same thing with update and delete.</p>
  
  <p>Is this possible to do?</p>