1

I have a very long program, and I have this problem. I have the following code:

<li>
    <label for="edit_cp">CP:</label>
    <input id="edit_cp" type="text" name="edit_cp" placeholder="Postal Code" required />

</li>

And In PHP:

$query = "SELECT    * FROM           shops";

$result = mysql_query($query);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo "<p style='font-size:12px'> <input type='radio' name='tienda' value='$row[ID]' required> $row[Nombre] ($row[Direccion])";
    }

mysql_close($link);

This is only a two parts of my program, so I can't use a form and get the $_POST or similar. I have to use the result of the edit_cp variable and use it into the php. I want it to calculate a nuber. For example if the entered number is for example 2 and in the while the number is 2, it will be selected.

3
  • @HenryTran Why using a Ajax call? Commented Nov 12, 2015 at 8:49
  • Can you give me an example? Commented Nov 12, 2015 at 8:49
  • If you want to use a variable from client, and you don't want to use a post-back, so you must do a thing to send the data to server. Ajax call will help you send the data to the server without any post-back. Commented Nov 12, 2015 at 8:55

1 Answer 1

1

Try

$.post( "path/to/handler", { edit_cp : $('#edit_cp').val()}).done(function( data ) {
    alert( "Data Loaded: " + data );
});

Don't forget to bind this script to some action, ex.:

$('#post').once('click',function(){
    $.post( "path/to/handler", { edit_cp : $('#edit_cp').val()}).done(
        function( data ) {alert( "Data Loaded: " + data );
        });
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.