Re: php image & javascript issue
| From: | Jochem Maas | Date: | Mon, 08 Sep 2008 17:47:19 +0000 |
| Subject: | Re: php image & javascript issue | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-279681@lists.php.net to get a copy of this message | ||
javasac schreef:
In my test.php file, I cannot run javascript and images do not show up. If I run this file using the URL http://localhost/index/?m=login&name=Sachinobviously you need to go a do some learning about: 1. continuously posting the same question over and over on a mailing list 2. URLs, namely the those that are relative and those that are absolute. 3. reading the error log of your webserver when you run http://localhost/index/?m=login&name=Sachin the files you can't see are being requested as follows: http://localhost/index/javascript/test.js http://localhost/index/style.css http://localhost/index/images/login.png and let me guess that those DON'T EXIST. which you would have realised if you bother to look in the webserver logs.
I can see 'My name is Sachin'. If I rename this file to test.html and open it, the image shows up and clicking on 'Click Me!' button works fine. Pls uncomment the tag when you run it. ======================================================= <html> <head>windows-1252 is not a very helpful charset, some people don't use windows.<meta http-equiv="Content-Type" content="text/html;charset=windows-1252">
do you know what an image tag is for? because merely putting a url in a file won't magically turn it into an image.<title>SPIDR</title> <script src="javascript/test.js" language="javascript"> </script> <link href="style.css" rel="stylesheet" type="text/css"></head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><!-- pls un comment it to test it --><!-- images/login.png -->
you also need to learn about input validation and output escaping.<p><input type="button" name="TEST" onclick="Hello()" value="Click Me!"/></p> <?php $name = $_GET['name']; echo 'My name is ' . $name;
?> </body> </html> ======================================================= test.js function Hello() { alert('Hello Ronaldo'); } ==============================================