473,507 Members | 3,706 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to write an action in javascript function

17 New Member
hi,
Below getRimData() is a function which will call .js file. It is included in
Expand|Select|Wrap|Line Numbers
  1. <html:select property="lbrokercd"  value="" onchange="document.forms[0], '/ILICTreasury/banker-web/X32.do', this, 'IX3201')">   
  2.  
---------> IT IS WROKING WELL

<head>
Expand|Select|Wrap|Line Numbers
  1. function doAction(){
  2. getRimData(document.forms[0], '/ILICTreasury/banker-web/X32.do', 
  3.                this, 'IX3201');
  4.         }
  5. </head>
  6. <body>
  7.  
  8. <html:select property="lbrokercd"  value="" onchange="doAction()" ----------> it is not calling getRimData ();
  9. <body>
  10.  
when ever the "doAction" is called it should execute the function "getRimData()".. but it is showing some error.


thx
HAN
Aug 2 '07 #1
5 1851
gits
5,390 Recognized Expert Moderator Expert
hi ...

at least you have to pass the this-variable to your function because getRimData awaits it:

Expand|Select|Wrap|Line Numbers
  1. onchange="doAction(this);"
kind regards
Aug 2 '07 #2
msg2ajay
17 New Member
hi,
i have alerady passed the 'this' in that but i am getting same error again



hi,

while copying from my page it just not copied.... the code is like this....
<html:select property="lbrokercd" value="" onchange="doAction()"/>

My question is how to call a method inside a javascript function?.Acutally my idea is as below.


Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.    <script language="javascript" src="../../js/module.js"></script>
  4.    <script language="javascript">
  5.       function domyAction(){
  6.                onemoreAction('arg1','arg2','arg3','arg4'); //-------> this described in .js file    
  7.         }
  8.          </script>
  9. </head>
  10. <body>
  11. <select onchange="domyAction()">
  12.   <option value ="volvo">Volvo</option>
  13.   <option value ="saab">Saab</option>
  14.   <option value ="opel">Opel</option>
  15.   <option value ="audi">Audi</option>
  16. </select>
  17. </body>
  18. </html>
  19.  
  20.  





thx,
Ajay
Aug 2 '07 #3
gits
5,390 Recognized Expert Moderator Expert
hi ...

i cannot see where you pass the this to your doAction-function ... however: have a look at the following example:

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.    <script type="text/javascript">
  4.  
  5.    function test(val) {
  6.        alert(val);
  7.    }
  8.  
  9.    function domyAction(obj) {
  10.        test(obj.value);
  11.    }
  12.  
  13.    </script>
  14. </head>
  15. <body>
  16. <select onchange="domyAction(this)">
  17.   <option value ="volvo">Volvo</option>
  18.   <option value ="saab">Saab</option>
  19.   <option value ="opel">Opel</option>
  20.   <option value ="audi">Audi</option>
  21. </select>
  22. </body>
  23. </html>
  24.  
kind regards
Aug 2 '07 #4
msg2ajay
17 New Member
i am giving tow code's of two files.
Case1,Case 2
in case1 my code is working fine but not working in case2... why?
In Case1 i placed my function getRimData() in 'onChange()',
bue in Case 2 i place in javascript function. what is the difference?



Expand|Select|Wrap|Line Numbers
  1. case 1:--->html:select onChange one javascript method is calling and it is wroking fine but i want, like case2:
  2.  
  3. case1:
  4. ------
  5. <body>
  6.  <html:select property="lbrokercd" styleClass="dropdown" value="${X32.lbrokercd}" onchange="getRimData(document.forms[0],'/ILICTreasury/banker-web/X32.do',this, 'IX3202');">
  7.        <html:option value="">Please Select</html:option>
  8.        <html:option value="1">1- HIDRO</html:option>
  9.        <html:option value="2">2- BI-HIDRO</html:option>
  10.        <html:option value="3">3- DI-HIDRO</html:option>
  11.        <html:option value="4">4- N-HIDRO</html:option>
  12. </html:select>
  13.  
  14. </body>
  15.  
  16.  
  17. --------------------------------------------------------------------------------------------------
  18.  
  19.  
  20.  
  21. case2:
  22.  
  23. <script>
  24.  
  25.        function doAction(){
  26.                 getRimData(document.forms[0],'/ILICTreasury/banker-web/X32.do',this, 'IX3202');
  27.         }
  28.  
  29. </script>
  30.  
  31. <body>
  32.  <html:select property="lbrokercd" styleClass="dropdown" value="${X32.lbrokercd}" onchange="doAction()">
  33.        <html:option value="">Please Select</html:option>
  34.        <html:option value="1">1- HIDRO</html:option>
  35.        <html:option value="2">2- BI-HIDRO</html:option>
  36.        <html:option value="3">3- DI-HIDRO</html:option>
  37.        <html:option value="4">4- N-HIDRO</html:option>
  38. </html:select>
  39.  
  40. </body>
  41.  
Aug 2 '07 #5
gits
5,390 Recognized Expert Moderator Expert
as i said ... have a look at the this-keyword ... it is a reference to the actual object in your case and you don't pass it to the doAction() function so getRimData() has another this as it needs!!!!! pass 'this' from the onchange to getRimData through the entire chain of calls! try the following:

[HTML]<script>
function doAction(obj) {
getRimData(
document.forms[0],
'/ILICTreasury/banker-web/X32.do',
obj,
'IX3202'
);
}
</script>
<body>
<html:select property="lbrokercd" styleClass="dropdown"
value="${X32.lbrokercd}" onchange="doAction(this)">
<html:option value="">Please Select</html:option>
<html:option value="1">1- HIDRO</html:option>
<html:option value="2">2- BI-HIDRO</html:option>
<html:option value="3">3- DI-HIDRO</html:option>
<html:option value="4">4- N-HIDRO</html:option>
</html:select>
</body>
[/HTML]

kind regards
Aug 2 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2507
by: Greg Brant | last post by:
my script is document.write("<!-- #include virtual\"http://www.where-ever.com/whatevere.html\" -->") but in the html (view source) i get ---------------------------------------------------...
2
2171
by: Bruce | last post by:
I have sucessfully used document.write in a new window, but I now wish to write to an already open & framed window. How do I do it. Please show example, as I have trouble getting my head around JS....
13
9585
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
7
2506
by: TJS | last post by:
what is wrong here, the submit will only post page back to itself instead of specifed action <SCRIPT language="Javascript"> function Submit_Form(){ document.Form1.Action="cart.asp";...
3
2150
by: francisco lopez | last post by:
I hope not sent I twice. ok here is my problem, the javascript form validation works perfect during I put a emaildirection in the <form action:""> comand, like this: <form...
3
3578
by: Paul Thompson | last post by:
I am working with a special tool which pre-processes the page. Using document.write, I am composing the page while it is loading, so I need to force a reprocess of the page AFTER the page loads. ...
4
2777
by: Mark Miller | last post by:
I've been trying to execute a javascript function just before submit on a form that contains an <input type="file"> input field and it isn't working. The reason I want to do this is the end users...
1
2919
by: Angelos | last post by:
Hello there, I am very new to Javascript and before I explain what I want I'll tell you in a few words that I am trying to make a button on a WYSIWYG text editor (RichArea) that previews on a...
4
1903
by: Notgiven | last post by:
This works: <input type="button" value="Add to list" onClick="addOption(param1, param2);"> But this doesn't: <img src="images/add.gif" onClick="addOption(param1, param2);"> The error I get...
0
7221
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7029
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3190
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1537
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.