0

I am passing a variable via the URL as var=5 to urlrun.php (like urlrun.php?var=5). There is a JavaScript function called testrun in urlrun.php.

Is there a way to call that JavaScript function depending on the value of that variable (var) passed through the URL?

For example, if($_GET['var']==5), I need to call that JavaScript function.

1 Answer 1

4

Put this somewhere:

<?php if($_GET['var'] == 5) { ?>
    <script type="text/javascript">
        testrun();
    </script>
<?php } ?>
Sign up to request clarification or add additional context in comments.

2 Comments

@look4php: It should. Try replacing the contents of testrun with a simple alert("testrun called"); and see if it works.
you should try if(intval($_GET['var']) == 5)

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.