JS控制DIV的显示隐藏
当选择按月付费则显示#pay1隐藏#pay2#pay3当选择按季付费则显示#pay2隐藏#pay1#pay3当选择按年付费则显示#pay3隐藏#pay1#pay2JS应该...
当选择 按月付费 则显示#pay1 隐藏#pay2 #pay3
当选择 按季付费 则显示#pay2 隐藏#pay1 #pay3
当选择 按年付费 则显示#pay3 隐藏#pay1 #pay2
JS应该怎么写
<p class="choose">请选择付费模式</p>
<p class="input_p">
<label class="bold"> <input type="radio" name="paytime" checked> 按月付费 </label>
<label> <input type="radio" name="paytime"> 按季付费 </label>
<label> <input type="radio" name="paytime"> 按年付费 </label>
</p>
<p class="choose">请选择开通服务时长</p>
<p class="input_p" id="paymonthly pay1" style="display: none">
<label><input type="radio" name="buytime" value="1" onClick="checkMonth(1)" > 一个月 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" value="2" onClick="checkMonth(2)" > 两个月 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" value="3" onClick="checkMonth(3)" > 三个月 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" onClick="checkMonth(4)" > 其他 <input name="buytime2" value="" type="text" id="othermonth" size="3" maxlength="2" class="border" style="ime-mode:disabled; border:1px solid #C4C4C4;" onkeyup="value=value.replace(/[^0-9]/g,'')" /> 个月 <span id="ot" class="pay_ps"></span></label>
</p>
<p class="input_p" id="payyearly pay2" style="display: none">
<label class="bold"><input type="radio" name="buytime" value="3" checked> 一季 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" value="6" > 两季 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" value="9" > 三季 <span class="pay_ps"></span></label>
</p>
<p class="input_p" id="payyearly pay3" style="display: none">
<label class="bold"><input type="radio" name="buytime" value="12" checked> 一年 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" value="24" > 两年 <span class="pay_ps"></span></label>
</p> 展开
当选择 按季付费 则显示#pay2 隐藏#pay1 #pay3
当选择 按年付费 则显示#pay3 隐藏#pay1 #pay2
JS应该怎么写
<p class="choose">请选择付费模式</p>
<p class="input_p">
<label class="bold"> <input type="radio" name="paytime" checked> 按月付费 </label>
<label> <input type="radio" name="paytime"> 按季付费 </label>
<label> <input type="radio" name="paytime"> 按年付费 </label>
</p>
<p class="choose">请选择开通服务时长</p>
<p class="input_p" id="paymonthly pay1" style="display: none">
<label><input type="radio" name="buytime" value="1" onClick="checkMonth(1)" > 一个月 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" value="2" onClick="checkMonth(2)" > 两个月 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" value="3" onClick="checkMonth(3)" > 三个月 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" onClick="checkMonth(4)" > 其他 <input name="buytime2" value="" type="text" id="othermonth" size="3" maxlength="2" class="border" style="ime-mode:disabled; border:1px solid #C4C4C4;" onkeyup="value=value.replace(/[^0-9]/g,'')" /> 个月 <span id="ot" class="pay_ps"></span></label>
</p>
<p class="input_p" id="payyearly pay2" style="display: none">
<label class="bold"><input type="radio" name="buytime" value="3" checked> 一季 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" value="6" > 两季 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" value="9" > 三季 <span class="pay_ps"></span></label>
</p>
<p class="input_p" id="payyearly pay3" style="display: none">
<label class="bold"><input type="radio" name="buytime" value="12" checked> 一年 <span class="pay_ps"></span></label>
<label><input type="radio" name="buytime" value="24" > 两年 <span class="pay_ps"></span></label>
</p> 展开
2个回答
展开全部
通过js获取radio的value值来控制p的隐藏显示(改动了你的源文件开头部分)
<label class="bold">
<input type="radio" value="1" name="paytime" checked onclick="selectPaytime(this.value)"> 按月付费 </label>
<label> <input type="radio" value="2" name="paytime" onclick="selectPaytime(this.value)"> 按季付费 </label>
<label> <input type="radio" value="3" name="paytime" onclick="selectPaytime(this.value)"> 按年付费 </label>
给你写个完整的js函数吧
<script type="text/javascript">
function selectPaytime(value)
{
if (value == 1)
document.getElementByID('paymonthly pay1').style.display= '';
document.getElementByID('payyearly pay2').style.display= 'none';
document.getElementByID('payyearly pay3').style.display= 'none';
}
if (value == 2)
{
document.getElementByID('paymonthly pay1').style.display= 'none';
document.getElementByID('payyearly pay2').style.display= '';
document.getElementByID('payyearly pay3').style.display= 'none';
}
if(value == 3)
{
document.getElementByID('paymonthly pay1').style.display= 'none';
document.getElementByID('payyearly pay2').style.display= 'none';
document.getElementByID('payyearly pay3').style.display= '';
}
</script>
<label class="bold">
<input type="radio" value="1" name="paytime" checked onclick="selectPaytime(this.value)"> 按月付费 </label>
<label> <input type="radio" value="2" name="paytime" onclick="selectPaytime(this.value)"> 按季付费 </label>
<label> <input type="radio" value="3" name="paytime" onclick="selectPaytime(this.value)"> 按年付费 </label>
给你写个完整的js函数吧
<script type="text/javascript">
function selectPaytime(value)
{
if (value == 1)
document.getElementByID('paymonthly pay1').style.display= '';
document.getElementByID('payyearly pay2').style.display= 'none';
document.getElementByID('payyearly pay3').style.display= 'none';
}
if (value == 2)
{
document.getElementByID('paymonthly pay1').style.display= 'none';
document.getElementByID('payyearly pay2').style.display= '';
document.getElementByID('payyearly pay3').style.display= 'none';
}
if(value == 3)
{
document.getElementByID('paymonthly pay1').style.display= 'none';
document.getElementByID('payyearly pay2').style.display= 'none';
document.getElementByID('payyearly pay3').style.display= '';
}
</script>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询