IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Passing Listboxes As Parameters To A Function
JORGEMAL
post Nov 3 2009, 03:33 PM
Post #1


Newbie
*

Group: Members
Posts: 7
Joined: 13-April 09
Member No.: 30,132



I have a web form with 3 pairs of listboxes, 6 listboxes total. I perform exactly the same actions in a pair by pair basis so I would like to use the same function code for the 3 pairs passing 2 listboxes as parameters depending on which pair will be used.

Is it possible to indicate a function that a parameter is a listbox?
Please advice.

Best regards,
Jorge Maldonado
Go to the top of the page
 
+Quote Post
justsomeguy
post Nov 3 2009, 05:01 PM
Post #2


The Old Man From Scene 24
*******

Group: Moderator
Posts: 14,826
Joined: 17-April 06
From: Phoenix
Member No.: 4,190
Languages: Focusing on PHP and JavaScript



You can send any arguments to a function. The arguments can be scalar variables like numbers or strings, or objects or functions or whatever else you want.
Go to the top of the page
 
+Quote Post
Deirdre's Dad
post Nov 3 2009, 05:20 PM
Post #3


Devoted Member
*****

Group: Members
Posts: 3,319
Joined: 16-January 08
Member No.: 19,529



The real question for me is HOW do you want to call them? It might make a difference if you call them from an change event or from a button. The concept is simple, but the actual syntax will change. Could you describe the situation a little more? Specifically, what event/element will call this function?
Go to the top of the page
 
+Quote Post
JORGEMAL
post Nov 3 2009, 07:26 PM
Post #4


Newbie
*

Group: Members
Posts: 7
Joined: 13-April 09
Member No.: 30,132



QUOTE (Deirdre's Dad @ Nov 3 2009, 12:20 PM) *
The real question for me is HOW do you want to call them? It might make a difference if you call them from an change event or from a button. The concept is simple, but the actual syntax will change. Could you describe the situation a little more? Specifically, what event/element will call this function?


The function shoudl be called from a button's click event. I am passing items from one listbox to the other so when I click a button then I add the selected item in the first listbox to the second listbox.

Regards,
Jorge Maldonado
Go to the top of the page
 
+Quote Post
justsomeguy
post Nov 3 2009, 07:42 PM
Post #5


The Old Man From Scene 24
*******

Group: Moderator
Posts: 14,826
Joined: 17-April 06
From: Phoenix
Member No.: 4,190
Languages: Focusing on PHP and JavaScript



It would probably make the most sense to have a function that accepts the IDs of the two boxes, where it can look up the selected record in the first one and add it to the second one. So all the function would need are the IDs of the two boxes, and you would use document.getElementById to access each select element and figure out which record is selected.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd November 2009 - 04:49 AM