Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jQuery另一个输入的动态输入值_Javascript_Jquery - Fatal编程技术网

Javascript jQuery另一个输入的动态输入值

Javascript jQuery另一个输入的动态输入值,javascript,jquery,Javascript,Jquery,我有三个项目,我正试图在页面上获得。前两个不是问题。第三个取决于第二个选择选项中选择的内容(如果需要更多详细信息)。第三个选项基于第二个选项隐藏或显示。所以没问题。代码如下: // Create a Javascript class to handle the form. function InquiryCardForm() { var objSelf = this; // Get a jQuery reference to the form. this.Form =

我有三个项目,我正试图在页面上获得。前两个不是问题。第三个取决于第二个选择选项中选择的内容(如果需要更多详细信息)。第三个选项基于第二个选项隐藏或显示。所以没问题。代码如下:

// Create a Javascript class to handle the form.
function InquiryCardForm() {
    var objSelf = this;

    // Get a jQuery reference to the form.
    this.Form = $( "#inqueryCard-form" );

    // Get jQuery references to the key fields in our contact
    // form. This way, we don't have to keep looking them up.
    // This will make it faster.
    this.DOMReferences = {
        // Form elements
        ID: this.Form.find( "input[ name = 'id' ]" ),
        SourceCode: this.Form.find( "input[ name = 'sourceCode' ]" ),
        SourceValue: this.Form.find( "select[ name = 'source' ]" ),
        SourceText: this.Form.find( "input[ name = 'other"
            +this.Form.find( "input[ name = 'sourceCode' ]" ).val()
            +this.Form.find( "select[ name = 'source' ]").val() +"' ]" )
    };
所以我有HTML:

<form action="" method="post" name="inqueryCard" id="inqueryCard-form">
...
    <tr>
        <td>
            <input type="hidden" name="sourceCode" value="SRCE">
            <select id="source" name="source">
                <option value="" selected>*** Select ***</option>
                <option value="1" data-more="N">Web Search</option>
                <option value="2" data-more="N">Word Of Mouth</option>
                <option value="3" data-more="O">Other</option>
                <option value="4" data-more="R">Other</option>
            </select>
        </td>
    </tr>
    <tr>
        <td>
            <div id="otherDIV_SRCE1">
                <p> <input type="text" name="otherSRCE1" value="" /></p>
            </div>
            <div id="otherDIV_SRCE2">
                <p> <input type="text" name="otherSRCE2" value="" /></p>
            </div>
            <div id="otherDIV_SRCE3">
                <p>Please Specify <input type="text" name="otherSRCE3" value="" /></p>
            </div>
            <div id="otherDIV_SRCE4">
                <p>Must Share <input type="text" name="otherSRCE4" value="" /></p>
            </div>
        </td>
    </tr>
但我想在this.dom中这样做。因为我在这个页面上有21个其他项目,它们的工作方式与此非常相似


先谢谢你。(第一次发布任何内容,如果我忘记了应该在这里的内容,请告诉我)

请更新您的功能:

function InquiryCardForm() 
{
    var objSelf = this;

    this.Form = $( "#inqueryCard-form" );

    var select = this.Form.find( "select[ name = 'source' ]" );

    this.DOMReferences = 
    {
        // Form elements
        ID: this.Form.find( "input[ name = 'id' ]" ),
        SourceCode: this.Form.find( "input[ name = 'sourceCode' ]" ),
        SourceValue: select ,
        SourceText: function()
        {
            var index = select.find(":selected").val();
            return this.Form.find( "input[ name = 'other" + SourceCode.val() + index + "' ]" );
        }
    };
}
function InquiryCardForm() 
{
    var objSelf = this;

    this.Form = $( "#inqueryCard-form" );

    var select = this.Form.find( "select[ name = 'source' ]" );

    this.DOMReferences = 
    {
        // Form elements
        ID: this.Form.find( "input[ name = 'id' ]" ),
        SourceCode: this.Form.find( "input[ name = 'sourceCode' ]" ),
        SourceValue: select ,
        SourceText: function()
        {
            var index = select.find(":selected").val();
            return this.Form.find( "input[ name = 'other" + SourceCode.val() + index + "' ]" );
        }
    };
}