Need the three "Options" to be hyperlinks that submit the "choice" form. When submitted, I would like the value to be the text of the option selected (i.e. value=Option1, Option2 orOption3) and all three to have the same name. (i.e. name = Options)

I saw this and some other posts here, but did not work with my set up - many "hyperlink inputs" within the form.

I'm also using JQuery now, if it can be done using that library, I saw some posts on their forum about this but not sure about the answers....

Any help is appreciated.

<form action="cgi.exe" method=POST name="choice">  
     <tbody>                    
         <tr>                    
           <td>Option1</td>
           <td>Option2</td>
           <td>Option3</td>
         </tr>
    </tbody> 
</form>

1 answer

o.k.w 2355
3
points

Here's one of the many ways to do it.

Script:

$(document).ready(function() {
  $('#choiceForm td').css('cursor','pointer').click(function(){
    $('#choiceForm input[type=hidden]').val($(this).text());
    $('#choiceForm').submit();
  });
});

HTML:

<form action="cgi.exe" method=POST id="choiceForm">  
<table>
     <tbody>                    
         <tr>                    
           <td>Option1</td>
           <td>Option2</td>
           <td>Option3</td>
         </tr>
    </tbody> 
</table><input type="hidden" name="choice" />
</form>
Answered almost 7 years ago by o.k.w