English 中文(简体)
j 质量——基于投入领域的变化隐藏价值
原标题:jQuery - Change hidden value based on input field

我正在利用一个形式领域来掌握特定局势的状况。 根据两个文本领域的意见,我需要一个隐蔽的领域来改变。 我将以英语描述这一功能。 帮助将这一文件翻译成一个能发挥作用的小册子将受到高度赞赏。

Hidden field equals yes where the value of field_1 equals 4 && field_2 equals 2 or Hidden field equals yes where the value of field_1 equals 3 && field_2 equals 1 or Hidden field equals yes where the value of field_1 equals 2 else Hidden field equals no

如说明的结构所示,I m a php开发商首先。 我的假设是,可以通过 j做到这一点。 否则,就为我提供一种选择。 感谢!

最佳回答

希望这一帮助。 http://api.jquery.com/“rel=“nofollow” 贵领域的情况有所不同(如检查箱)。

var field1 = parseInt($( #field_1 ).val());
var field2 = parseInt($( #field_2 ).val());

if((field1 == 4 && field2 == 2) || (field1 == 3 && field2 == 1) || field1 == 2){
   $( #hidden ).val( yes )
} else {
   $( #hidden ).val( no )
}
问题回答

下面是利用关键活动手来根据外地投入价值1和外地2 (假设它们是案文投入)修改隐藏的投入价值。

$( #field1 #field2 ).keyup(function() {
    var field_1 = parseInt($( #field_1 ).val());
    var field_2 = parseInt($( #field_2 ).val());

    if (field_1 == 4 && field_2 == 2) {
        $( #hidden ).val( yes );
    }
    else if (field_1 == 3 && field_2 == 1) {
        $( #hidden ).val( yes );
    }
    else if (field_1 == 2) {
        $( #hidden ).val( yes );
    }
    else {
        $( #hidden ).val( no );
    }
});




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签