jquery设置javascript变量的值

时间:2016-04-28 21:02:01

标签: javascript jquery forms

好的,我现在有部分工作了。当我单击续订类型“续订”单选按钮选项时,它会检查nameReservation1单选按钮并触发功能以更新定价计算器并显示BINnum ID。 但是,当我点击续订类型“新注册”单选按钮选项时,它不会检查nameReservation0单选按钮,但它会更新我的表单计算器中显示的定价。

此外,当我单击nameReservation选项时,它根本不会更改定价(显示金额或总数)。这些仍然需要独立可点击,但只能使用新注册续订类型选项。

<script>
$(function() {
$('.renewaltype').change(function() {
 if($(this).val() == 'New Registration') {$('#BINnum').hide('500');} {$( "#nameReservation0" ).prop( "checked", true );$( "#nameReservation1" ).prop( "checked", false ); checkRadioRT();Form_Calculator();}
if($(this).val() == 'Renewal') {$('#BINnum').show('500');} {$( "#nameReservation1" ).prop( "checked", true );$( "#nameReservation0" ).prop( "checked", false ); checkRadioRT();Form_Calculator();}
});
});
</script>  

 <script>
 $(function() {
 $('.nameReservation').change(function() {
 if($(this).val() == 'With Mandatory Name Reservation'){$('#dispNoReserve').hide('500');} {checkRadioNR();Form_Calculator();}
 if($(this).val() == 'Without Mandatory Name Reservation') {$('#dispNoReserve').show('500');} {checkRadioNR();Form_Calculator();} 
 });
 });
 </script>  

Javascript函数叫

function checkRadioNR() { 
var i;
//checking which radio button selected 
for ( i = 0;  i < theForm.nameReservation.length; i++) {

if (theForm.nameReservation[i].checked == true) {   
    switch(i)
    {
        case 0:         
        theForm.price_NR.value = accounting.formatMoney('45.00');
        price_NR = 45.00;       
        break

        case 1:             
        theForm.price_NR.value = accounting.formatMoney('');
        price_NR = 0;
        break
       }            
     }
     }  
     } 


  function checkRadioRT() { 
  var i;
  //checking which radio button selected 
  for ( i = 0;  i < theForm.renewaltype.length; i++) {

   if (theForm.renewaltype[i].checked == true) {   
    switch(i)
    {
        case 0:         
        theForm.price_NR.value = accounting.formatMoney('45.00');
        price_NR = 45.00;       
        //document.getElementById("NUANS").checked = true;
        break

        case 1:             
        theForm.price_NR.value = accounting.formatMoney('');
        price_NR = 0;
        document.getElementById("nameReservation1").checked  == true;
        //document.getElementById("NUANS").checked = false;
        break
        }           
        }
        }   
        } 

function checkRadioNR() { 
var i;
//checking which radio button selected 
for ( i = 0;  i < theForm.nameReservation.length; i++) {

 if (theForm.nameReservation[i].checked == true) {   
    switch(i)
    {
        case 0:         
        theForm.price_NR.value = accounting.formatMoney('45.00');
        price_NR = 45.00;       
        //document.getElementById("NUANS").checked = true;
        break

        case 1:             
        theForm.price_NR.value = accounting.formatMoney('');
        price_NR = 0;
        //document.getElementById("NUANS").checked = false;
        break
       }            
       }
       }    
       } 

单选按钮的HTML代码

<div class="col-sm-9">
      <div class="radio">
          <label>
        <input name="nameReservation" class="nameReservation" id="nameReservation1" type="radio" onClick="checkCheckbox(); Form_Calculator();" value="Without Mandatory Name Reservation">
               <span class="custom-check2"></span> <strong>Without Mandatory Name Reservation</strong>
           </label>
        </div>                
        </div>     

0 个答案:

没有答案