java - How to validate when RadioButton is selected? -


i'm trying validate when select radiobutton inside jsp form , make selection refresh page content want. i'm planning use these radiobuttons way of selecting categories.

this form code:

<form name="login" action="procesaradd.do">     <br>      <b>categoria</b>     <br>     <input type="radio" name="g1" value="per" checked="checked" />perfume     <input type="radio" name="g1" value="joy" />joyas     <input type="radio" name="g1" value="car" />bolso carteras          <table border="1">             <tbody>                 <tr>                     <td>id producto</td>                     <td><input type="text" name="id" value="" /></td>                 </tr>                 <tr>                     <td>nombre</td>                     <td><input type="text" name="nombre" value="" /></td>                 </tr>                 <tr>                     <td>stock</td>                     <td><input type="text" name="stock" value="" /></td>                 </tr>                 <tr>                     <td>precio</td>                     <td><input type="text" name="precio" value="" /></td>                 </tr>                                 </tbody>         </table>      <br> 

i need show different images depending on selection of radio button, , take information on form create new product database. have no knowledge of javascript , i'm wondering if can done plain java or html.

you can using jquery show below:

html -

<form id="myform">   <input type="radio" name="radioname" value="1" /> 1 <br />   <input type="radio" name="radioname" value="2" /> 2 <br />   <input type="radio" name="radioname" value="3" /> 3 <br /> </form> 

jquery -

$(function(){   $('#myform input').on('change', function() {    alert($('input[name=radioname]:checked', '#myform').val());    }); }); 

instead of displaying alert, can call whatever ajax request want make or whatever function call wish make backend.

you can experiment more on here: http://plnkr.co/edit/gist:2006604?p=preview. can read more jquery's :checked pseudo-class here: https://api.jquery.com/checked-selector/.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo