SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jul 2007
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    function with in a function in javascript

    hi,
    how to invoke a javascript function with a javascript function. as below the action should cause if onChange occurs.

    Code:
    <html>
    <head>
             <script language="javascript">
                    function domyAction(){
                     onemoreAction('arg1,arg2,arg3,arg4'); //-------> this described in .js file                }
             </script>
    </head>
    <body>
    <select onchange="domyAction()">
      <option value ="volvo">Volvo</option>
      <option value ="saab">Saab</option>
      <option value ="opel">Opel</option>
      <option value ="audi">Audi</option>
    </select>
    </body>
    </html>

    thx,
    Ajay

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If onemoreAction() takes four arguments, then you must remove the single quotes. As written you call onemoreAction() with a single string argument.

    You're also missing the closing brace in your function declaration (it's commented out). The language attribute of the <script> has been deprecated for almost a decade, while the type attribute is required. Your code should probably be,
    Code:
    <script type="text/javascript">
      function domyAction(){
          onemoreAction(arg1, arg2, arg3, arg4);
      }
    </script>
    Birnam wood is come to Dunsinane


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
  •