How to Call .js file(functions) at onclick the image

Discussion in 'HTML & Website Design' started by amritpalpathak, Oct 9, 2010.

  1. #1
    i have two file
    1)Html=which has html code..
    2).js file which has 2 functions

    Problem);;i want when i click the image , .js file(its fucntions) should be called and image should be resized according to the code..
    But what i am doing ,it is not being doing

    1)contents of html file is as under


    <html>
    <body>

    <body onload="changeIt();">
    <head>

    <script langauge="javascript">

    function changeIt()
    {

    var width=50;
    var height=50;
    document.image.width=width
    document.image.height=height


    }

    </script>
    </head>


    <img src="/home/administrator/Desktop/aa.jpeg" name="image" onclick=src="/var/www/external.js/changeeIt();">

    </body>
    </html>


    2)Content of .js file is as under



    function changeeIt()

    {
    if(count==1)
    {
    var width=500
    var height=500
    document.image.width=width
    document.image.height=height
    count=2;
    }
    else if(count==2)
    {
    var amrit1=50
    var pal=50
    document.image.width=amrit1
    document.image.height=pal
    count=1;

    }


    }




    Please somebody help

    Thanks in advance
     
    amritpalpathak, Oct 9, 2010 IP
  2. zicoone

    zicoone Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <img src="a.jpg" id="myImg" onclick="this.style.width='500px';this.style.height='500px';" style="width:50px;height:50px"/>
    Code (markup):
     
    zicoone, Oct 9, 2010 IP
  3. amritpalpathak

    amritpalpathak Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    zicoone,i think u didnt get the problem,bt thanks for reply.

    <img src="a.jpg" id="myImg" onclick="this.style.width='500px';this.style.height='500px';" style="width:50px;height:50px"/>



    actully the problem is .js file has the 2 function that has the coding for resizeing the image.. but i am unable to call .js file at image click

    please help me how to call(syntax) .js file from html file when image is clicked
     
    amritpalpathak, Oct 10, 2010 IP
  4. Joy mds

    Joy mds Peon

    Messages:
    150
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    <html>
    <body>
    <body onload="changeIt();">
    <head>
    <script langauge="javascript">
    function changeIt()
    {

    var width=50;
    var height=50;
    document.image.width=width
    document.image.height=height
    }
    </script>
    </head>
    <img src="/home/administrator/Desktop/aa.jpeg" name="image" onclick=src="/var/www/external.js/changeeIt();">
    </body>
    </html>

    And this is the .js file

    function changeeIt()
    {
    if(count==1)
    {
    var width=500
    var height=500
    document.image.width=width
    document.image.height=height
    count=2;
    }
    else if(count==2)
    {
    var amrit1=50
    var pal=50
    document.image.width=amrit1
    document.image.height=pal
    count=1;
    }
    }
     
    Joy mds, Oct 12, 2010 IP