下拉值没有变化 [英] dropdown values is not changing

查看:84
本文介绍了下拉值没有变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <  !DOCTYPE   html   PUBLIC    -//W3C//DTD   XHTML     1.0  过渡//EN"     <   html     ="   http://www.w3.org/1999/xhtml" > 
<  头部 > 
<      ="   Content-Type"   内容  ="  text/html; charset = iso-8859-1" / > 
<  标题 > 无标题文档<  /title  > 
<  脚本    ="  文本/javascript" <  /script  > 
<  /head  > 

<  正文 > 

          <  输入    ="  名称   rad"     =" 购买"  onclick    doClick(this);" >   b  <  /b  <  输入    ="  名称   rad"     ="  RENT"  onclick    doClick(this);" >   b  <  /b  <   p  > 预算<  /p  > 
        <  选择    ="   min"    ="  购买" <  选项   <  > 
          <  选项 >  5Lakhs <  /option  > 
          <  选项 >  10Lakhs <  /option  > 
          <  选项 >  20Lakhs <  /option  > 
          <  选项 >  25Lakhs <  /option  > 
          <  选项 >  30Lakhs <  /option  > 
           <  选项 >  35Lakhs <  /option  > 
          <  选项 >  40Lakhs <  /option  > 
          <  选项 >  45Lakhs <  /option  > 
          <  选项 >  50Lakhs <  /option  > 
        <  /select  > 
        <   span     ="  <  > 
            <  选择    ="   buymax"  ="   max" > ; 
          <  选项 >  Max <  /option  > 
          <  选项 >  10Lakhs <  /option  > 
        <  选项 >  30Lakhs <  /option  > 
        <  选项 >  40Lakhs <  /option  > 
          <  选项 >  50Lakhs <  /option  > 
          <  选项 >  60Lakhs <  /option  > 
         <  选项 >  70Lakhs <  /option  > 
          <  选项 >  80Lakhs <  /option  > 
          <  选项 >  90Lakhs <  /option  > 
          <  选项 >  1crore <  /option  > 
        <  /select  > 


<  选择    ="   rent" 样式  显示:无"   最小" <  选项   >  MinRent /option  <  选项 >  5000 <  /option  > 
          <  选项 >  8000 <  /option  > 
          <  选项 >  10000 <  /option  > 
          <  选项 >  15000 <  /option  > 
          <  选项 >  20000 <  /option  > 
           <  选项 >  30000 <  /option  > 
          <  选项 >  35000 <  /option  > 
          <  选项 >  45000 <  /option  > 
          <  选项 >  50000 <  /option  > 
          <  选项 >  60000 <  /option  > 
           <  选项 >  1Lakh <  /option  > 
        <  /select  > 
               <   span     ="  <  > 
       <  选择    ="   rent" 样式  显示:无"   最大值" <  选项 >  MaxRent <  /option  > 
          <  选项 >  10000 <  /option  > 
          <  选项 >  15000 <  /option  > 
          <  选项 >  20000 <  /option  > 
          <  选项 >  25000 <  /option  > 
          <  选项 >  30000 <  /option  > 
          <  选项 >  35000 <  /option  > 
          <  选项 >  45000 <  /option  > 
          <  选项 >  50000 <  /option  > 
          <  选项 >  1 Lakh <  /option  > 
           <  选项 >  1Lakh + <  /option  > 
        <  /select  > 

<  /body  > 
<  /html  >  

解决方案

不清楚您的要求是什么...但是...
如果您的JavaScript代码有问题...

1)您的if条件将永远不会通过..

if (objRad.value=="rent")


修改为

if (objRad.value=="RENT")



2)根据您的需要编写其他条件的代码.


 <  !DOCTYPE     html   PUBLIC  "-//W3C //DTD     XHTML     1.0    过渡//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"  > 
<   html     ="   http://www.w3.org/1999/xhtml" > 
<  头部 > 
<      ="   Content-Type"   内容  ="  text/html; charset = iso-8859-1" / > 
<  标题 > 无标题文档<  /title  > 
<  脚本    ="  文本/javascript" <  /script  > 

/script>
<  脚本 >  

(文档).ready(function(){ //var val1 ="; //var val2 =";


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function doClick(objRad){
if (objRad.value=="rent"){
document.getElementById("rent").style.display='block';
document.getElementById("buymin").style.display='none';
document.getElementById("buymax").style.display='none';  //show other options
}

}
</script>
</head>

<body>

          <input type="radio" name="rad" value="BUY" onclick="doClick(this);" ><b>BUY</b>
                 <input type="radio" name="rad" value="RENT" onclick="doClick(this);" ><b>RENT</b>

         <p>Budget</p>
        <select class="min"  id="buymin">
          <option >Min</option>
          <option>5Lakhs</option>
          <option>10Lakhs</option>
          <option>20Lakhs</option>
          <option>25Lakhs</option>
          <option>30Lakhs</option>
           <option>35Lakhs</option>
          <option>40Lakhs</option>
          <option>45Lakhs</option>
          <option>50Lakhs</option>
        </select>
        <span style="position:relative; top:6px; left:10px; color:#FFFFFF">To</span>
            <select id="buymax"class="max">
          <option>Max</option>
          <option>10Lakhs</option>
        <option>30Lakhs</option>
        <option>40Lakhs</option>
          <option>50Lakhs</option>
          <option>60Lakhs</option>
         <option>70Lakhs</option>
          <option>80Lakhs</option>
          <option>90Lakhs</option>
          <option>1crore</option>
        </select>


<select id="rent" style="display:none" class="min">
<option >MinRent</option>
          <option>5000</option>
          <option>8000</option>
          <option>10000</option>
          <option>15000</option>
          <option>20000</option>
           <option>30000</option>
          <option>35000</option>
          <option>45000</option>
          <option>50000</option>
          <option>60000</option>
           <option>1Lakh</option>
        </select>
               <span style="position:relative; top:6px; left:10px; color:#FFFFFF">To</span>
       <select id="rent" style="display:none" class="max">
          <option>MaxRent</option>
          <option>10000</option>
          <option>15000</option>
          <option>20000</option>
          <option>25000</option>
          <option>30000</option>
          <option>35000</option>
          <option>45000</option>
          <option>50000</option>
          <option>1 Lakh</option>
           <option>1Lakh +</option>
        </select>

</body>
</html>

解决方案

Not clear with what you have asked... But...
If you are having issue with your javascript code...

1) Your if condition will never be through..

if (objRad.value=="rent")


Modify it to

if (objRad.value=="RENT")



2) Write code for else condition as per your need.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
function doClick(objRad){
if (objRad.value=="RENT"){
document.getElementById("RENTMIN").style.display='block';
document.getElementById("RENTMAX").style.display='block';
document.getElementById("buymin").style.display='none';
document.getElementById("buymax").style.display='none';  //show other options
}

else
{
document.getElementById("RENTMIN").style.display='none';
document.getElementById("RENTMAX").style.display='none';

document.getElementById("buymin").style.display='block';
document.getElementById("buymax").style.display='block';
}
}


</script>

/script>
<script>


(document).ready(function() { //var val1 = ""; //var val2 = "";


这篇关于下拉值没有变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆