Making a loop that changes field count
|
| View previous topic :: View next topic |
| Author |
Message |
jntcomputers
Joined: 25 Feb 2007 Posts: 5
|
Posted: Sun Mar 04, 2007 7:36 pm Post subject: Making a loop that changes field count |
|
|
I have a form that allows people to click 'Show More' and a second row pops up. The field is a drop dow populated by js. The problem I am having is assigning the new number to the js for drop list population. What I have so far is:
| Code: |
function showMoreWashers()
{
items+=1;
if (items < 12) {
document.getElementById('showMoreWashers').innerHTML += '<table border="0" width="100%" cellpadding="0" cellspacing="0" class="subTable"><tr><td><select name="washerA'+items+'"><Option value="" ></option></select></td><td style="padding-right: 1px;"><input class="num" name="washerqtyA'+items+'" type="text" value="" size=3></td><td style="padding-left: 2px;"><select name="washerB'+items+'"></select></td><td><input class="num" name="washerqtyB'+items+'" type="text" value="" size=3"></td></tr></table>';
}
else {
alert("Only 12 products can be compared!");
}
for (var i=0; i < prodlist1.length;++i){
addOption(document.ordform.washerA2, prodlist1[i], [i]);
}
for (var i=0; i < prodlist1.length;++i){
addOption(document.ordform.washerA3, prodlist1[i], [i]);
}
for (var i=0; i < prodlist1.length;++i){
addOption(document.ordform.washerA4, prodlist1[i], [i]);
}
for (var i=0; i < prodlist1.length;++i){
addOption(document.ordform.washerA5, prodlist1[i], [i]);
}
|
... and so on...
But this populates each one before it.. so when 3 is populated, another set is added to 2. I need something like this:
| Code: |
| addOption(document.ordform.washerA[items], prodlist1[i], [i]); |
But the browser doesn't seem to like this!!! Any ideas? |
|
| Back to top |
|
 |
|
|
sachav
Joined: 03 Mar 2007 Posts: 32
|
Posted: Mon Mar 05, 2007 3:11 am Post subject: Re: Making a loop that changes field count |
|
|
Can you reformulate your question or put your thing online?
I don't understand |
|
| Back to top |
|
 |
jntcomputers
Joined: 25 Feb 2007 Posts: 5
|
Posted: Mon Mar 05, 2007 6:52 pm Post subject: Re: Making a loop that changes field count |
|
|
What I have is a form, with dropdowns for washerA1, washerB1. THey are populated with a javascript that is run when the page is opened:
| Code: |
| addOption(document.ordform.washerA1, prodlist1[i], [i]); |
And below is a link that adds another row with washerA2, washerB2... upt to 5 time (washerA5, washerB5)...
So, I have the code to populate each new dropdown:
| Code: |
for (var i=0; i < prodlist1.length;++i){
addOption(document.ordform.washerA2, prodlist1[i], [i]);
}
|
Evertime a new row is added, the var washerCount is incresed to reflect the row number... the number in washerA2.
I am trying to use the var washerCount to populate the new droplist... instead of making a new call to the addOPtion function for each new row...
I will post a link as soon as I get it online![/code] |
|
| Back to top |
|
 |
|
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums. Click here to Register
If you are a current member here on DEVPPL, please login below:
|
|
|
|