Results 1 to 3 of 3

Thread: how can i pass span'id to .js page

  1. #1
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how can i pass span'id to .js page

    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. #2
    Join Date
    May 2006
    Location
    Alaska
    Posts
    163
    Thanks
    5
    Thanked 2 Times in 2 Posts

    Default

    How are you passing it? You're not even using parameters. I think you could do: An external file:
    Code:
    function dscptAction(span){
    var obj = document.getElmentsByTagName(span);
    for(i=0;i<obj.length;i++){
    ............
    .........
    .....
    }
    }/*You forgot this one...*/
    Then add:
    Code:
    onclick="dscptAction('theSpan');"
    I think that would work, but I don't even understand what you're trying to do.

  3. #3
    Join Date
    Jul 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    my module.js file
    ----------------
    Code:
    <script type="text/javascript>
    
    function doDscptAction(field, span){
                var  dscptVal= field.value;
                var obj = span;
                for(i=0;i<obj.length;i++){
                        if (dscptVal == '001'){
                                 document.getElementById("enq").style.display="inline";
                                 document.getElementById("nam").style.display="inline";
                                 document.getElementById("cpActno").style.display="none";
                                 document.getElementById("trandt").style.display="none";
    }
    </script>
    my html code:
    --------------
    Code:
    <html:html>
    <head>
    <script language="javascript" src="../../js/module.js"></script>
    <head>
    <body>
    
     <tr>
         <td width="13%" class="labeltext">Transaction Code</td>
         <td width="1%"  class="blanktext">:</td>
         <td colspan="4" class="blanktext">
         <html:select property="dscpt" styleClass="dropdown" value="${X00.dscpt}" onchange="doDscptAction(this,spanid)">// iam trying to pass this,spanid here     
         <html:option value="001">001 - Agent1 </html:option>
         <html:option value="002">003 - Nostro </html:option>
                            </html:select>
                        </td>
                    </tr>
                </table>
                    
                <span id="trans" style="display:none">
                  <table width="100%">
                  <tr>
                  <td width="13%" class="labeltext">Transaction Type</td>
                   <html:select property="transtype" styleClass="dropdown" value="${X00.transtype}"onclick="forex(this)">
                         <html:option value=""></html:option>
                         <html:option value="02">02 - SENEX</html:option>
                         <html:option value="04">04 - ONLINE</html:option>
                    </html:select>
                            </td>
                        </tr>
                        </table>
                        </span>
    </body>
    </html:html>

Bookmarks

Posting Permissions

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