多次填充功能无效

时间:2014-04-03 07:48:03

标签: javascript php mysql

我正在处理从mysql填充自动完成列表的文本框,这一切都正常。问题是,无论何时从列表中选择一个项目,它总是将其填入第一个具有“函数填充(thisValue)”的文本框中。我似乎无法让多个填充函数适用于每个文本框。

的javascript:

function lookup(inputString)
{
    if(inputString.length == 0)
    {
        $('#suggestions').hide();
    }    
    else     
    {    
        $.post("sql_naam_klant.php", {queryString: ""+inputString+""}, function(data)    
        {   
    if(data.length >0)    
    {    
        $('#suggestions').show();    
        $('#autoSuggestionsList').html(data);
    }
        });
    }
}

function fill(thisValue) 
{
    $('#naam_klant').val(thisValue);
    setTimeout("$('#suggestions').hide();", 200);        
}

function lookup2(inputString)
{
    if(inputString.length == 0)
    {
        $('#suggestions2').hide();
    }    
    else     
    {    
        $.post("sql_boekingsnummer.php", {queryString: ""+inputString+""}, function(data)    
        {   
    if(data.length >0)    
    {    
        $('#suggestions2').show();    
        $('#autoSuggestionsList2').html(data);
    }
        });
    }
}

function fill2(thisValue) 
{
    $('#boekingsnummer').val(thisValue);
    setTimeout("$('#suggestions2').hide();", 200);        
}

function lookup3(inputString)
{
    if(inputString.length == 0)
    {
        $('#suggestions3').hide();
    }    
    else     
    {    
        $.post("sql_bedrag_van_boete.php", {queryString: ""+inputString+""}, function(data)    
        {   
    if(data.length >0)    
    {    
        $('#suggestions3').show();    
        $('#autoSuggestionsList3').html(data);
    }
        });
    }
}

function fill3(thisValue) 
{
    $('#bedrag_van_boete').val(thisValue);
    setTimeout("$('#suggestions3').hide();", 200);        
}

function lookup4(inputString)
{
    if(inputString.length == 0)
    {
        $('#suggestions4').hide();
    }    
    else     
    {    
        $.post("sql_distributiekanaal.php", {queryString: ""+inputString+""}, function(data)    
        {   
    if(data.length >0)    
    {    
        $('#suggestions4').show();    
        $('#autoSuggestionsList4').html(data);
    }
        });
    }
}

function fill4(thisValue) 
{
    $('#distributiekanaal').val(thisValue);
    setTimeout("$('#suggestions4').hide();", 200);        
}

function lookup5(inputString)
{
    if(inputString.length == 0)
    {
        $('#suggestions5').hide();
    }    
    else     
    {    
        $.post("sql_huiscode.php", {queryString: ""+inputString+""}, function(data)    
        {   
    if(data.length >0)    
    {    
        $('#suggestions5').show();    
        $('#autoSuggestionsList5').html(data);
    }
        });
    }
}

function fill5(thisValue) 
{
    $('#huiscode').val(thisValue);
    setTimeout("$('#suggestions5').hide();", 200);        
}

function lookup6(inputString)
{
    if(inputString.length == 0)
    {
        $('#suggestions6').hide();
    }    
    else     
    {    
        $.post("sql_huursom.php", {queryString: ""+inputString+""}, function(data)    
        {   
    if(data.length >0)    
    {    
        $('#suggestions6').show();    
        $('#autoSuggestionsList6').html(data);
    }
        });
    }
}

function fill6(thisValue) 
{
    $('#huiscode').val(thisValue);
    setTimeout("$('#suggestions6').hide();", 200);        
}

function lookup7(inputString)
{
    if(inputString.length == 0)
    {
        $('#suggestions7').hide();
    }    
    else     
    {    
        $.post("sql_opmerking.php", {queryString: ""+inputString+""}, function(data)    
        {   
    if(data.length >0)    
    {    
        $('#suggestions7').show();    
        $('#autoSuggestionsList7').html(data);
    }
        });
    }
}

function fill7(thisValue) 
{
    $('#opmerking').val(thisValue);
    setTimeout("$('#suggestions7').hide();", 200);        
}

HTML:

<td class="tdfilter">
            <label>Opmerking</label>
            <input type="text" name="huursom" size="20" id="Opmerking" onkeyup="lookup7(this.value);" onblur="fill();" >    
            <div class="suggestionsBox" id="suggestions7" style="display: none;">
            <div class="suggestionList" id="autoSuggestionsList7">
            </div>
            </div>
        </td> 
        <td class="tdfilter">
            <label>huursom</label>
            <input type="text" name="huursom" size="20" id="huursom" onkeyup="lookup6(this.value);" onblur="fill();" >    
            <div class="suggestionsBox" id="suggestions6" style="display: none;">
            <div class="suggestionList" id="autoSuggestionsList6">
            </div>
            </div>
        </td> 
        <td class="tdfilter">
            <label>huiscode</label>
            <input type="text" name="huiscode" size="20" id="huiscode" onkeyup="lookup5(this.value);" onblur="fill();" >    
            <div class="suggestionsBox" id="suggestions5" style="display: none;">
            <div class="suggestionList" id="autoSuggestionsList5">
            </div>
            </div>
        </td> 
        <td class="tdfilter">
            <label>Distributiekanaal</label>
            <input type="text" name="boekingsnummer" size="20" id="distributiekanaal" onkeyup="lookup4(this.value);" onblur="fill();" >    
            <div class="suggestionsBox" id="suggestions4" style="display: none;">
            <div class="suggestionList" id="autoSuggestionsList4">
            </div>
            </div>
        </td> 
        <td class="tdfilter">
            <label>Bedrag van boete</label>
            <input type="text" name="bedrag_van_boete" size="20" id="bedrag_van_boete" onkeyup="lookup3(this.value);" onblur="fill();" >    
            <div class="suggestionsBox" id="suggestions3" style="display: none;">
            <div class="suggestionList" id="autoSuggestionsList3">
            </div>
            </div>
        </td>            
        <td class="tdfilter">
            <label>Boekingsnummer</label>
            <input type="text" name="boekingsnummer" size="20" id="boekingsnummer" onkeyup="lookup2(this.value);" onblur="fill();" >    
            <div class="suggestionsBox" id="suggestions2" style="display: none;">
            <div class="suggestionList" id="autoSuggestionsList2">
            </div>
            </div>
        </td>
        <td class="tdfilter">
            <label>Naam klant</label> 
            <input type="text" name="naam_klant" size="20" id="naam_klant" onkeyup="lookup(this.value);" onblur="fill();" >    
            <div class="suggestionsBox" id="suggestions" style="display: none;">
            <div class="suggestionList" id="autoSuggestionsList">
            </div>
            </div>
        </td>

0 个答案:

没有答案