dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: jquery repeat it self in every repeated field

  1. #1
    Join Date
    Jan 2014
    Posts
    1

    Angry jquery repeat it self in every repeated field

    i making a drug storage inventory im using jquery to search for items to insert its quantity , when i repeat every item fields and search for second item and choose it from list , it changes the previews item to the same one like the second one i choose .

    here is an example

    PHP Code:

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
    function lookup(inputString) {
        if(inputString.length == 0) {
            // Hide the suggestion box.
            $('#suggestions').hide();
        } else {
            $.post("rpc3.php", {queryString: ""+inputString+""},
     function(data){
                if(data.length >0) {
                    $('#suggestions').show();
                    $('#autoSuggestionsList').html(data);
                }
            });
        }
    } // lookup
    function fzl(thisValue) {
        $('.inputString').val(thisValue);
        setTimeout("$('#suggestions').hide();", 200);
    }
    function fzlz(thisValue) {
        $('.inputStringz').val(thisValue);
    }

    function fzlzo(thisValue) {
        $('.inputStringzo').val(thisValue);
    }
    </script>


                 <form action="send.php" method="post" name="theform" onsubmit="return formCheck(this);" autocomplete='off'>

    <table>

       <tr>

        <td><label>name</label></td>

                    <td><input style="text-align: right" type="text" size="30" value="" class="inputString" onkeyup="lookup(this.value);" onblur="fzl();" name="drug" />
             <div class="suggestionsBox" id="suggestions" style="display: none; z-index:10; position: absolute;">

                <div class="suggestionList" id="autoSuggestionsList" lang="ar">
                    &nbsp;
                </div>
            </div></td>

           <td><label>code</label></td>


          <td><input style="text-align: right" type="text" size="30" value="" class="inputStringz"  onkeyup="lookup(this.value);" onblur="fzlz();" name="code" /></td>

          <td><label>unit</label></td>

           <td><input style="text-align: right" type="text" size="30" value="" class="inputStringzo"  onkeyup="lookup(this.value);" onblur="fzlzo();" name="unit" /></td>            

            </tr>

            <tr>

        <td><label>name</label></td>

                    <td><input style="text-align: right" type="text" size="30" value="" class="inputString" onkeyup="lookup(this.value);" onblur="fzl();" name="drug" />
             <div class="suggestionsBox" id="suggestions" style="display: none; z-index:10; position: absolute;">

                <div class="suggestionList" id="autoSuggestionsList" lang="ar">
                    &nbsp;
                </div>
            </div></td>

           <td><label>code</label></td>


          <td><input style="text-align: right" type="text" size="30" value="" class="inputStringz"  onkeyup="lookup(this.value);" onblur="fzlz();" name="code" /></td>

          <td><label>unit</label></td>

           <td><input style="text-align: right" type="text" size="30" value="" class="inputStringzo"  onkeyup="lookup(this.value);" onblur="fzlzo();" name="unit" /></td>            

            </tr>

    </table>
    </form> 
    and this is the php file (rpc3.php)


    PHP Code:

    <?php

    include 'config.php';
    if(isset(
    $_POST['queryString'])) {
            
    $queryString $_POST['queryString'];
            if(
    mb_strlen($queryString) > 1) {
    $selc "SELECT * FROM `drug_info` WHERE `dru_name` LIKE '%$queryString%' LIMIT 10";
    $result mysql_query ($selc);
    while (
    $row mysql_fetch_array ($result))
    {
        
    $code $row ["dru_code"];
        
    $name $row ["dru_name"];
        
    $unit $row ["dru_unit"];
        
    $barcode $row ["dru_barcode"];
        echo (
    '<li onClick="fzl(\''.$name .'\');fzlz(\''.$code .'\');fzlzo(\''.$unit .'\');fzlzb(\''.$barcode .'\')">' $name '</li>');
    }
            }
    }

    ?>

    i need to repeat it more about 10 times ... any help please for dis problem

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,589
    Why is this question in Javascript when it should be in the Javascript Frameworks forums?
    If your post falls off the page, bump it. ...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles