本文介绍了如何使用Jquery在DropDown的Selected值上设置文本框中的值。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HEllO团队,



我的代码如下:

有三种不同的控件如下:

1.One Textbox如下:

HEllO Team,

I have the code as follows:
There are three different Controls as follows:
1.One Textbox as follows:

<td>
    <input type="text" id="topCountForQCTextbox" style="width: 90px;" />
                    </td>







2.DropDown As Follows:




2.DropDown As Follows:

<td>
                       <select id="allocateToSelect" class="combo150">
                        </select>
                   </td>





3.Label如下



3.Label as follows

<td>
                       <label id="allocateToQCCountLabel">
                           QC Count :
                       </label>
                   </td>





我的Func如下:

用户将从DropDown中选择值,并且值将显示在Label.But我需要执行以下条件:



First Condition。

当我从DropDown.On中选择任何选定值时,在文本框(topCountForQCTextbox)中我想将值设置或显示为0(零)。



第二个条件:

其次,当我将值放入时,前一个值0(零)被删除文本框,



i使用了jquery For textbox(topCountForQCTextbox),如下所示:



My Functionality as follow :
User will select the value from DropDown and value will get display in Label.But There are Condition which I need To Perform as Follows:

First Condition.
when i am selecting the any selected value from DropDown.On that time ,In textbox ("topCountForQCTextbox") i want to set or display the value as 0(zero).

Second Condition:
Secondily, The previous value that is 0 (zero) get removed , when i am putting the value in textbox,

i have used the jquery For textbox ("topCountForQCTextbox") as follows:

function allocateQCEntity() {
            var allocateQC = cloneObject(blankQCAllocationEntity);
            
            allocateQC.TopCountForQC = $('#topCountForQCTextbox').val();

            if (allocateQC.TopCountForQC == null || allocateQC.TopCountForQC == '') {
                allocateQC.TopCountForQC == '0';
            }
            
            return allocateQC;
        }



一切正常,但我想验证这个条件。

当页面加载时,在文本框上(topCountForQCTextbox )没有值存在,它是空白的。

当我从DropDown.On中选择任何选定值时,在文本框(topCountForQCTextbox)中我想将值设置或显示为0(零)。



其次,当我将值放在文本框中时,前一个值0(零)被删除,



我试过这个但没有用


Everything is working ,But i want to validate this Conditions.
When page load ,on textbox ("topCountForQCTextbox") no values is present ,it is blank .
when i am selecting any selected value from DropDown.On that time ,In textbox ("topCountForQCTextbox") i want to set or display the value as 0(zero).

Secondily, The previous value that is 0 (zero) get removed , when i am putting the value in textbox,

I have try this but no use

if (allocateQC.TopCountForQC == null || allocateQC.TopCountForQC == '') {
                    $('#topCountForQCTextbox').val(0);
                }



它设置textbox为空时的值,但是当我把任意数字设置为1或2时,它也将值设为0 ,我不想要。当我把任何值1,2,3 ...所以那时文本框值得到拾取而不是0(零)。



如何验证???。我需要在我的代码中进行哪些更改。

请指导我。



亲切协助。



谢谢

Harshal


It set the value when textbox is empty,but when i put the any number that is 1 or 2 ,then also it getting the value as 0 ,which i dont want.when i put any value that is 1 ,2 3 ... so on that time textbox value get pickup not 0 (Zero).

How do i validate ???.What changes i need to make in my Code.
Please Guide me.

Kindly Assist.

Thanks
Harshal

推荐答案



一切正常,但我想验证这个条件。

当页面加载时,在文本框上(topCountForQCTextbox )没有值存在,它是空白的。

当我从DropDown.On中选择任何选定值时,在文本框(topCountForQCTextbox)中我想将值设置或显示为0(零)。



其次,当我将值放在文本框中时,前一个值0(零)被删除,



我试过这个但没有用


Everything is working ,But i want to validate this Conditions.
When page load ,on textbox ("topCountForQCTextbox") no values is present ,it is blank .
when i am selecting any selected value from DropDown.On that time ,In textbox ("topCountForQCTextbox") i want to set or display the value as 0(zero).

Secondily, The previous value that is 0 (zero) get removed , when i am putting the value in textbox,

I have try this but no use

if (allocateQC.TopCountForQC == null || allocateQC.TopCountForQC == '') {




它设置textbox为空时的值,但是当我把任意数字设置为1或2时,它也将值设为0 ,我不想要。当我把任何值1,2,3 ...所以那时文本框值得到拾取而不是0(零)。



如何验证???。我需要在我的代码中进行哪些更改。

请指导我。



亲切协助。



谢谢

Harshal


It set the value when textbox is empty,but when i put the any number that is 1 or 2 ,then also it getting the value as 0 ,which i dont want.when i put any value that is 1 ,2 3 ... so on that time textbox value get pickup not 0 (Zero).

How do i validate ???.What changes i need to make in my Code.
Please Guide me.

Kindly Assist.

Thanks
Harshal


这篇关于如何使用Jquery在DropDown的Selected值上设置文本框中的值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 05:10