Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Making a loop that changes field count



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
jntcomputers



Joined: 25 Feb 2007
Posts: 5

PostPosted: Sun Mar 04, 2007 7:36 pm    Post subject: Making a loop that changes field count Reply with quote

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
View user's profile Send private message
sachav



Joined: 03 Mar 2007
Posts: 32

PostPosted: Mon Mar 05, 2007 3:11 am    Post subject: Re: Making a loop that changes field count Reply with quote

Can you reformulate your question or put your thing online?
I don't understand
Back to top
View user's profile Send private message
jntcomputers



Joined: 25 Feb 2007
Posts: 5

PostPosted: Mon Mar 05, 2007 6:52 pm    Post subject: Re: Making a loop that changes field count Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
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:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap