I have a form with 3 radio buttons and 3 text boxes , on click of a radio button one input field shows up and other two hides (using jQuery). Now I wish to submit the form by filling the two hidden fields with some default values , I have tried to assign values to this two hidden fields but it didn't worked ,
Please help me , here's what i have tried till know and an unable to assign values to the hidden text field .
$(document).ready(function(){
$('input[type="radio"]').click(function(){
if($(this).attr("value")=="red"){
$(".box").hide();
$(".red").show();
}
if($(this).attr("value")=="green"){
$(".box").hide();
$(".green").show();
}
if($(this).attr("value")=="blue"){
$(".box").hide();
$(".blue").show();
}
});
});
.box{
padding: 20px;
display: none;
margin-top: 20px;
border: 1px solid #000;
}
.red{ background: #ff0000; }
.green{ background: #00ff00; }
.blue{ background: #0000ff; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>
<label><input type="radio" name="colorRadio" value="red"> red</label>
<label><input type="radio" name="colorRadio" value="green"> green</label>
<label><input type="radio" name="colorRadio" value="blue"> blue</label>
</div>
<form id="myform">
<div class="red box">
<input type="text" >
</div>
<div class="green box"><input type="text" ></div>
<div class="blue box"><input type="text" ></div>
<input type="submit">
</form>