By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,528 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

passin array values in javascript functions

P: 1
my code is
Expand|Select|Wrap|Line Numbers
  1. for(i=0;i<5;i++)
  2. {
  3.  
[HTML] <input type="text" name="date1[]">

<input type="text" name="date2[]">[/HTML]
Expand|Select|Wrap|Line Numbers
  1. }
i want to compare between two dates(which are in loops above) through the javascript function (onChange)checkDate(date1,date2)
how do i pass the dates in the function above??
Any help will be highly appreciated..
thanks a lot in advance
Nov 6 '07 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Welcome to TSDN!

onchange of which element?

You can use the strings "date1[]" and "date2[]" passed as date1 and date2, then in the function, use:
Expand|Select|Wrap|Line Numbers
  1. document.getElementsByName(date1)[0]
(the [0] selects the first element because getElementsByName returns an array).
Nov 6 '07 #2

Post your reply

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