Text not wrapped to POST variable

Here is the HTML: Line 18 below does not wrap $_POST['storename']

after clicking Submit. All other text boxes wrap just fine. The only difference is that it is autocomplete with data from the database using PHP and AJAX. I have linked all encodings regarding this field.

Here's a link to the site: http://drmwebdesign.com/project002/product-insert.php

<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
    <div class="row uniform 50%">
        <div class="6u 12u(mobilep)">
            <input type="text" name="pname" id="pname" value="<?php echo $pname;?>" placeholder="Product Name" />
        </div>
        <div class="6u 12u(mobilep)">
            <input type="text" name="brand" id="brand" value="<?php echo $brand;?>" placeholder="Product Brand" />
        </div>
        <div class="6u 12u(mobilep)">
            <input type="text" name="price" id="price" value="<?php echo $price;?>" placeholder="Product Price" />
        </div>
        <div class="6u 12u(mobilep)">
            <input type="text" name="upc" id="upc" value="<?php echo $upc;?>" placeholder="Product UPC" />
        </div>
    </div>
    <div class="row uniform">
        <div class="12u">
            <input type="text" name="storename" id="storename" class="form-control" placeholder="Enter Store Name" />
            <div id="storeList"></div>
        </div>
        <div class="12u">
            <ul class="actions align-center">
                <li><input type="submit" value="Submit Product" /></li>
            </ul>
        </div>
    </div>
</form>

      

<script>
    $(document).ready(function(){
        $('#storename').keyup(function(){
            var query = $(this).val();
            if(query != '')
            {
                $.ajax({
                    url:"php/storelist.php",
                    method:"POST",
                    data:{query:query},
                    success:function(data)
                    {
                        $('#storeList').fadeIn();
                        $('#storeList').html(data);
                    }
                });
            }
        });
        $(document).on('click', 'li', function(){
            $('#storename').val($(this).text());
            $('#storeList').fadeOut();
        });
    });
</script>

      

+3


source to share


2 answers


$(document).on('click', 'li', function(){
    $('#storename').val($(this).text());
    $('#storeList').fadeOut();
});

      



Triggers, when you click the submit button, set the #storename value to nothing.
Add a class to store names and click onclick using that.

0


source


Try this: 1) Use chrome net to test the request / response 2) If the field contains long data, check the max message size 3) If the field is a list and you select multiple options, you need to check this question 4) check if the multiple fields the same name / id



0


source







All Articles