Perfect, the getElementById method is working perfectly, cheers.  Good catch
on guessing what I was actually asking for as well, this page will have
anything from 1 to a few hundred form rows so an if/else set would have been
way to big (which is why I didn't go that route myself).

--
Jay

-----Original Message-----
From: morgan l [mailto:[EMAIL PROTECTED] 
Sent: 07 November 2007 17:52
To: CF-Community
Subject: Re: JS Question

function updateCC(rowNum) {
       document.prices("cc" + rowNum).value = document.prices("cost" +
rowNum).value * 1.2;
}

But it's widely considered better practice to use document.getElementById()
rather than document.formname to reference form fields. To do so, just ad
id="" to the fields, and the function would become:

function updateCC(rowNum) {
       document.getElementById("cc" + rowNum).value =
document.getElementById("cost" + rowNum).value * 1.2;
}

On 11/7/07, James Smith <[EMAIL PROTECTED]> wrote:
>
> Quick question I am sure someone will answer in no time...
>
> How do I modify the function...
>
> function updateCC(rowNum) {
>        document.prices.cc1.value = document.prices.cost1.value * 1.2;
> }
>
> So that if 'rowNum' is 4 then 'cc1' becomes 'cc4' and 'cost1' becomes
> 'cost4'.
>
> --
> Jay
>
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.5.503 / Virus Database: 269.15.23/1114 - Release Date:
> 06/11/2007
> 20:05
>
>
>
> 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Download the latest ColdFusion 8 utilities including Report Builder,
plug-ins for Eclipse and Dreamweaver updates.
http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta

Archive: 
http://www.houseoffusion.com/groups/CF-Community/message.cfm/messageid:246043
Subscription: http://www.houseoffusion.com/groups/CF-Community/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.5

Reply via email to