0

i want to get the number in text field and send it in Url methode GET ;

$(document).ready(function () {
            $("#go").click(function() {
                var n = document.getElementById('nombre').value;
                alert("Chess.php?number=9");
                $('#chess').load("Chess.php?number="+n);    
            });

the value :

<input type="text" name="nombre" id="nombre">

3 Answers 3

2

Try again with code below:

$(document).ready(function () {
    $('#go').click(function() {
        $.get('Chess.php', { number: $('#nombre').val() } );
    });
});

PS: Its stranger the attribute value called nombre and the field called number. Change this too. Other tip is dont use Uppercase for the url, use only 'chess.php'.

I hope to help you.

Sign up to request clarification or add additional context in comments.

Comments

1

There's a missing }) ...

Plus you have to add in the head section of your script the following :

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>

<script type="text/javascript">

$(document).ready(function () 
{
    $("#go").click(function() 
    {
        var n = document.getElementById('nombre').value;
        alert("Chess.php?number=9");
        $('#chess').load("Chess.php?number="+n);    
    })
});

</script>

Comments

0

it works now like this

$(document).ready(function () {
    $("#go").click(function() {
        $('#chess').load("Chess.php?number="+document.getElementById('nombre').value);
    });
});

1 Comment

Use jQuery for the document.getElementById('nombre').value.

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.