Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 21-07-2010
Member
 
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.!!
Reply With Quote
  #2  
Old 21-07-2010
Member
 
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.
Reply With Quote
  #3  
Old 21-07-2010
Member
 
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.
Reply With Quote
  #4  
Old 21-07-2010
Member
 
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.
Reply With Quote
  #5  
Old 21-07-2010
Member
 
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()"
Reply With Quote
  #6  
Old 21-07-2010
Member
 
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
	 )
 )
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 02:55 AM.