View Full Version : calculate with generated names

05-29-2004, 11:00 PM
Hi There,

First I'll try to explain what I want to achieve.
I want to make a calculator for the total duration of a CD.

When the page loads, you can choose with a <SELECT>-tag how much songs there are on the CD.
When you select 12 the script generates 12 rows with on each row 2 <INPUT>-tags, the first for the minutes, the other for the seconds. So far no problems.

At the bottom of the page, I put a button to calculate the total time on that CD. I created the right formulas, which works fine.

Here comes the problem:
I tried to give the generated <INPUT>-tags all a different name so I can use those names in the calculations, but I can't get it right.

The HTML-code looks like this:
<SCRIPT LANGUAGE="JavaScript" src="Generate.js"></SCRIPT>
<FORM name=counter>
Number of Songs on CD:
<SELECT size=1 name=number onChange="createList(counter.number.value); showtable();">
<OPTION value=1 selected>01</OPTION>
<OPTION value=2>02</OPTION>
<OPTION value=3>03</OPTION>
t/m 30
<TR><TD colspan=3 align=center height=50 valign=bottom><SPAN id=but></SPAN></TD></TR>
<TR><TD colspan=3 align=center height=50 valign=bottom><SPAN id=tot></SPAN></TD></TR>

The generated <INPUT>-tags looks like this:
<INPUT type='text' size=2 maxlength=2 name=" + inter + "min" + I + inter + "'>
inter="'"; and "I" is a number so when it works as I want, there should be created a name like this: "min02" or "min13".

I only need to know if the generated names will work this way and how I can use them in my calculate function.

Can anybody help me please?

Sorry for the bad English, but keep in mind I live in the Netherlands.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum