IT Community - Software Programming, Web Development and Technical Support

Looping through Fields

This is a discussion on Looping through Fields within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi all..... Can anyone discuss briefly about the looping through fields. Thanks & Regards P.vinothkumar...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 10-16-2007, 03:55 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Looping through Fields

Hi all.....


Can anyone discuss briefly about the looping through fields.

Thanks & Regards
P.vinothkumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-16-2007, 03:57 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Re: Looping through Fields

Hi all...

How can I retrieve all the selected items form all the select form fields in a form?

Thanks.....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 10-16-2007, 04:00 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default How can I retrieve all the selected items form all the select form fields in a form?

Hi....


<FORM NAME="formName">

<SELECT NAME="select1name">
<OPTION VALUE="">Pick One:
<OPTION VALUE="apple">Apple
<OPTION VALUE="orange">Orange
<OPTION VALUE="banana">Banana
</SELECT>

<SELECT NAME="select2name">
<OPTION VALUE="">Pick One:
<OPTION VALUE="cider">Cider
<OPTION VALUE="juice">Juice
<OPTION VALUE="milkshake">Milkshake
</SELECT>

<INPUT TYPE="BUTTON" onClick="cycle()" VALUE="Check">

<BR>

<INPUT TYPE="TEXT" NAME="answer">

</FORM>

<SCRIPT LANGUAGE="JavaScript">
function cycle() {
var answer = '';
for (var i = 0; i<document.formName.elements.length; i++) {
if ((document.formName.elements[i].name.indexOf('select') > -1)) {
if (document.formName.elements[i].selectedIndex != 0) {
answer += document.formName.elements[i].options[document.formName.elements[i].selectedIndex].value + ' ';
}
}
}
document.formName.answer.value = answer;
}
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript1.1">
function cycle() {
var answer = '';
for (var i = 0; i<document.formName.elements.length; i++) {
if ((document.formName.elements[i].type == 'select-one')) {
if (document.formName.elements[i].selectedIndex != 0) {
answer += document.formName.elements[i].options[document.formName.elements[i].selectedIndex].value + ' ';
}
}
}
document.formName.answer.value = answer;
}
</SCRIPT>

Thanks......
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 10-16-2007, 04:02 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Re: Looping through Fields

Hi all...

How do I display the value of each text field using a for loop?

Thanks & Regards
P.vinothkumar
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 10-16-2007, 04:05 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default How do I display the value of each text field using a for loop?

Hi....

<form name="formName">
<input type="text" name="myTextA" value="apple">
<input type="text" name="myTextB" value="orange">
<input type="text" name="myTextC" value="banana">
<input type="text" name="myTextD" value="pear">
<input type="text" name="myTextE" value="peach">
<input type="text" name="myTextF" value="grape">

<input type="button" onClick="cycle()" value="Check">

<br>

<input type="text" name="answer" size="60">

</form>

<script language="JavaScript">
function cycle() {
var answer = '';
for (var i = 0; i<document.formName.elements.length; i++) {
if ((document.formName.elements[i].name.indexOf('Text') > -1)) {
answer += document.formName.elements[i].value + ' ';
}
}
document.formName.answer.value = answer;
}
</script>

Thanks....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 10-16-2007, 04:06 AM
Pvinothkumar Pvinothkumar is offline
D-Web Analyst
 
Join Date: Sep 2007
Posts: 237
Pvinothkumar is on a distinguished road
Default Re: Looping through Fields

Hi all...

How can I access form fields in a table by looping through column and row numbers?

Thanks....
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 10-16-2007, 04:08 AM
itbarota itbarota is offline
D-Web Architect
 
Join Date: Jun 2007
Posts: 547
itbarota is on a distinguished road
Default How can I access form fields in a table by looping through column and row numbers?

Hi...

<form name="tableForm">
<table>
<tr><td><input name="col0row0"></td><td><input name="col1row0"></td><td><input name="col2row0"></td><td><input name="col3row0"></td></tr>
<tr><td><input name="col0row1"></td><td><input name="col1row1"></td><td><input name="col2row1"></td><td><input name="col3row1"></td></tr>
<tr><td><input name="col0row2"></td><td><input name="col1row2"></td><td><input name="col2row2"></td><td><input name="col3row2"></td></tr>
<tr><td><input name="col0row3"></td><td><input name="col1row3"></td><td><input name="col2row3"></td><td><input name="col3row3"></td></tr>
<tr><td><input name="col0row4"></td><td><input name="col1row4"></td><td><input name="col2row4"></td><td><input name="col3row4"></td></tr>
</table>
</form>

Thanks...
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I disable form fields? GDevakii HTML, CSS and Javascript Coding Techniques 7 08-04-2008 07:04 PM
is possible to extract the values in the below fields?.. kingmaker C# Programming 1 02-27-2008 09:53 PM
how to code for php validation in all fields gk_cloud PHP Programming 4 10-09-2007 12:03 AM
Game looping in j2me amansundar Game Development 8 09-10-2007 05:16 AM
looping structures in Ruby? vadivelanvaidyanathan Ruby 1 08-18-2007 01:53 AM


All times are GMT -7. The time now is 01:19 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0