0

Here's my JS code...

function da(){
    var a=document.forms["user"]["age"].value;
    if(this.age.value < 18 || this.age.value > 85) {
        alert('some text...');
        this.age.focus();
        return false;
    }else{
        window.location.href='file.php?&'+a;
    }
}

It simply passes the parameters to the page where I'm standing... Here's the form just in case (I'm a beginner keep in mind)...

<form name="buscar" method="GET"> Some text <input                 onmouseover="Aj2('d');document.getElementById('box').style.display='block';" onmouseout="clean();" type="number" name="age" id="age" > Age <div id="help" ><!-- --> </div><br />
<input type="button" value="Send" onclick="da()">
</form>

The Aj2 function is not the problem here... Thanks for any help y might get...

3

2 Answers 2

0

Just a thought, if you don't actually have to reload the page and just want to get information to your javascript code from PHP, you could do something like

<script>

<?
    $phpvariable = "my variable";
?>

var jsvariable = <?php echo json_encode($phpvariable); ?>;

</script>

Now the javascript variable, jsvariable, will hold the PHP variable's content.

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

Comments

0

Some thing like this I am not a expert.

$('button name').on('click', function() {
   var age_ = document.getElemenetById('age');
   $.get('path of your file', {'age' : age_}, function(resp) {
        // code to pass parameter
        alert(age_);
   });
});

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.