Connecting Tech Pros Worldwide Forums | Help | Site Map

How to get a specific input field from input fields list share a same name?

Newbie
 
Join Date: Jan 2008
Location: Malaysia
Posts: 28
#1: Jun 25 '09
Hi, I have multiple input fields which is sharing similiar elements name so it will submit a array to other page.
Whereas, i encounter a problem now, i want get number third element from the list in order to do specific change by javascript function.
How i suppose to do to get the element with the element name, any possible method to do it?

prabirchoudhury's Avatar
Familiar Sight
 
Join Date: May 2009
Location: Wellington, New Zealand
Posts: 152
#2: Jun 25 '09

re: How to get a specific input field from input fields list share a same name?


could you mention some sample code, that would make easier ..
1. input field declare with a ID and in javascript call that ID getElemenetById(id_name) would do your job.
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#3: Jun 25 '09

re: How to get a specific input field from input fields list share a same name?


Another option is to use document.getElementsByName():
Expand|Select|Wrap|Line Numbers
  1. var elems = document.getElementsByName("element_name");
  2. var third_elem = elems[2];
Reply


Similar JavaScript / Ajax / DHTML bytes