tonybabb
01-27-2014, 02:45 PM
Good morning,
I'm trying to make a div appear/ disappear based on which radio button a user clicks. Initially the div is hidden, when the user clicks "Yes" the div correctly appears but when the user clicks "No" it remains visible. I added a couple of alerts and it seems that the radio button value is always seen as "Yes".
What I'm trying to do is when the user answers "yes" to the first question, then the second question should appear, but if they change their mind and then click "No" the second question should disappear.
Here's part of the page:
<p>Will you be selling Products and/ or services during the rally?</p>
<input type="radio" id="selly" name="sell" value="yes" /> <label for="selly">Yes</label><br />
<input type="radio" id="selln" name="sell" value="no" /> <label for="selln">No</label>
<div id="haveBl" hidden="true">
<p>Do you already have a City of Hollister Business License (valid during the rally)?</p>
<p>
<label>
<input type="radio" name="havebl" value="Yes" id="havebly" />
Yes</label>
<br />
<label>
<input type="radio" name="havebl" value="No" id="havebln" />
No</label>
<br />
</p>
</div> <!-- /haveBl -->
and here's the js
<script>
$('input[name=sell]').click(function() {
if (sell = "yes")
{
$('#haveBl').show();
alert ("selly = " + sell);
}
else
{
$('#haveBl').hide();
alert ("selln = " + sell);
};
});
</script>
The full page can be seen here http://www.hollisterairshow.com/rally
Thanks for any direction you can give. The learning curve on js seems quite steep - at least where I am.....
Tony
I'm trying to make a div appear/ disappear based on which radio button a user clicks. Initially the div is hidden, when the user clicks "Yes" the div correctly appears but when the user clicks "No" it remains visible. I added a couple of alerts and it seems that the radio button value is always seen as "Yes".
What I'm trying to do is when the user answers "yes" to the first question, then the second question should appear, but if they change their mind and then click "No" the second question should disappear.
Here's part of the page:
<p>Will you be selling Products and/ or services during the rally?</p>
<input type="radio" id="selly" name="sell" value="yes" /> <label for="selly">Yes</label><br />
<input type="radio" id="selln" name="sell" value="no" /> <label for="selln">No</label>
<div id="haveBl" hidden="true">
<p>Do you already have a City of Hollister Business License (valid during the rally)?</p>
<p>
<label>
<input type="radio" name="havebl" value="Yes" id="havebly" />
Yes</label>
<br />
<label>
<input type="radio" name="havebl" value="No" id="havebln" />
No</label>
<br />
</p>
</div> <!-- /haveBl -->
and here's the js
<script>
$('input[name=sell]').click(function() {
if (sell = "yes")
{
$('#haveBl').show();
alert ("selly = " + sell);
}
else
{
$('#haveBl').hide();
alert ("selln = " + sell);
};
});
</script>
The full page can be seen here http://www.hollisterairshow.com/rally
Thanks for any direction you can give. The learning curve on js seems quite steep - at least where I am.....
Tony