0

How should I call jquery from my php page?

This is my php page:

<form action="#" method="post">
    <input type="file" name="fileInput" id="fileInput" />
    <input type="submit" value="submit" disabled />
</form>
<div id="result"></div>

And this is the js file:

$(document).ready(
    function(){
        $('input:file').change(
            function(){
                if ($(this).val()) {
                    $('input:submit').attr('disabled',false);
                }
            }
            );
    });

Thanks!

5
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by blackxswil
0

If both your js file and jquery are linked in your page, then this code will execute automatically when the page is done loading.

0

use

<script></script>

and put your code in between them on PHP Page.

Edited by ayesha789: due to Speling mistake

0

How should I call jquery from my php page?

This is my php page:

<form action="#" method="post">
    <input type="file" name="fileInput" id="fileInput" />
    <input type="submit" value="submit" disabled />
</form>
<div id="result"></div>

And this is the js file:

$(document).ready(
    function(){
        $('input:file').change(
            function(){
                if ($(this).val()) {
                    $('input:submit').attr('disabled',false);
                }
            }
            );
    });

Thanks!

Suppose you have your JavaScript code in a file 'yourFile.js'. Your PHP and JavaScript file should be in the same directory. In php file, just add

<script type="text/javascript" src="yourFile.js"></script>

This line of code should be placed before the <head> tag. If your page dpnt have any <head> tag and only PHP code, then just add the line at the begining of the PHP file

0

When I put the js file link on the head; the link is as follow:

<script src="jquery.js" type="text/javascript"></script>

I got the error as follows:
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Win64; x64; Trident/4.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0; AskTB5.6)
Timestamp: Wed, 16 Feb 2011 00:38:36 UTC


Message: Object expected
Line: 2
Char: 1
Code: 0
URI: http://localhost/picturetopic/jquery.js

0

Please downlaod latest Jquery File from the official website and use it, its very simple issue.

0

Thanks guys! I solved it.
Yes, after i download the latest js file, it worked!
Thanks again

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.