Results 1 to 6 of 6

Thread: Problem when calling a Javascript function

  1. #1
    Join Date
    Dec 2009
    Posts
    59

    Problem when calling a Javascript function

    I am having problems while calling the Javascript function while loading jsp. Since, I have recently started doing this, I am not having enough knowledge about it. How can call a JavaScript function to run whenever a particular show jsp? Onload event would be similar to html, not if I have explained well. I think that there should be someone who has good knowledge about this topic. I am requesting to all those person to help me with proper explanation. Any other information would be greatly appreciable.!! Any sample of coding would be helpful.!!

  2. #2
    Join Date
    Mar 2008
    Posts
    192

    Re: Problem when calling a Javascript function

    If you want to call the function, I would say that you will have to do the same way as in HTML :
    HTML Code:
    <body onload="javascript:funcion();">
     ...
     </ Body>
    And if you use any library, sure you have some form as a function ready () in jQuery.

  3. #3
    Join Date
    Mar 2008
    Posts
    232

    Re: Problem when calling a Javascript function

    The basics:
    Code:
    <script>
         window.onload = function () (...  )
     </ Script>
    And just in case you have other scripts that should run when the page loads, you could do:
    Code:
    <script>
         oldonload = window.onload;
         window.onload = function () (oldonload (); ...  )
     </ Script>
    Or what locovich says that if you use some library (Prototype, jQuery, Mootools, etc.) to help you manage the event management and drivers, then even better. Surely there have a (...) or $ Event.observe (document). Ready (...) or something similar.

  4. #4
    Join Date
    Dec 2009
    Posts
    59

    Re: Problem when calling a Javascript function

    Thanks everyone for trying to help me. I have a menu with options :
    Code:
    function reset () ( 
    document.form1.option.checked = 0 
    ) 
    
    ... 
    name="form1" <form method="post" action="/servlet/inform"> 
    id="timporte" <table width="390"> 
    <tr> 
    <input <td> type="radio" name="option" value="radiobutton"> </ td> 
    <td> Media </ td> 
    </ Tr> 
    <tr> 
    <input type="radio" name="option" <td> value="radiobutton"> </ td> 
    <td> Sum </ td> 
    </ Tr> 
    <tr> 
    <input type="radio" name="option" <td> value="radiobutton"> </ td> 
    <td> Intevalo </ td> 
    </ Tr> 
    <tr> 
    <td height="50"> </ td> 
    <td colspan="2"> <a href = "#" onclick = "javascript : Reset ()">< img src = "icons \ botonreset.png" name = "reset"> </ a> 
    </ Td> 
    </ Tr> 
    </ Table> 
    </ Form>
    I am having the problem while calling the Javascript function here. What I do is that when you tighten the link will deselect the option that has been tight. My problem is that a hyperlink does not, however, if instead of put a hyperlink button image type (<input name = "reset" type = "image" src = "\ icons \ botonreset.png" onClick = " javascript : ()">) Reset ... so if it works. But I can not put a button because I will tighten the page listed in the action of the form. That I can do? So please explain me this scenario properly.

  5. #5
    Join Date
    Apr 2008
    Posts
    193

    Re: Problem when calling a Javascript function

    How are you trying to call the function from the link..?? so
    <a href="resetear()"> or <a href = "javascript : Reset () ">
    I say this because I see that you write this
    Code:
    onClick = "javascript : Reset () ">
    to call a function with no need to put onclick
    onclick = "javascript : Reset () "but onclick ="reset()"

  6. #6
    Join Date
    Oct 2008
    Posts
    167

    Re: Problem when calling a Javascript function

    You should also know the basic things while calling a Javascript function. It passes through each of the elements that share the name. You can try the following code :
    Code:
    function reset () (
     for (m = 0, m <document.form1.option.length; m + +) (
    	 document.form1.option[m]. checked = false
    	 )
     )

Similar Threads

  1. Calling a JavaScript function from Flash
    By Allison in forum Software Development
    Replies: 5
    Last Post: 08-02-2011, 04:58 PM
  2. Calling JavaScript from Managed Code
    By Computer_Freak in forum Tips & Tweaks
    Replies: 1
    Last Post: 03-08-2010, 03:31 PM
  3. c# function equivalent to gettime function in javascript
    By Omaar in forum Software Development
    Replies: 4
    Last Post: 10-03-2010, 10:44 PM
  4. Problem with the parameters of JavaScript function
    By Luis234 in forum Software Development
    Replies: 4
    Last Post: 16-03-2009, 11:12 AM
  5. Calling Struts using Javascript
    By Novino in forum Software Development
    Replies: 2
    Last Post: 25-10-2008, 02:42 PM

Tags for this Thread

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
  •  
Page generated in 1,713,494,173.30112 seconds with 17 queries