Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    how can i pass span'id to .js page through javascript Function

    Code: ( text )
    <html>
    function dscptAction(){
    var obj = document.getElementsByTagName("span");
    for(i=0;i<obj.length;i++){
    ............
    .........
    .....
    }

    <body>
    <span>
    <table >
    <tr>
    <td>
    <select value="" onclick="dscptAction()">
    </option value="1">1</option>
    </option value="2">2</option>
    </td>
    </tr>
    </table>
    </span>
    <span id ="dscpt">
    <table>
    </table>
    </span>
    <span id ="addr">
    <table>
    </table>
    </span>
    </body>
    </html>


    i am want to place my javascript{"dscptAction()"} function to the .js file, In this case how can i pass the 'span'Id to javascript.

    for example:



    Code: ( text )
    <html>
    <script language="javascript" src="../../js/module.js"></script> // this contains my dscptAction() function....
    <head>


    </head>
    <body>
    <span id="name">
    <table >
    <tr>
    <td>
    <select value="" onclick="dscptAction()">
    </option value="1">1</option>
    </option value="2">2</option>
    </td>
    </tr>
    </table>
    </span>
    <span id ="dscpt">
    <table>
    </table>
    </span>
    <span id ="addr">
    <table>
    </table>
    </span>

    </body>
    </html>





    thx,
    Ajay

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Putting the Javascript code in an external js file works the same as having the code inline. Calling the function will be the same.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •