Return value based upon visibility of form field?

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Nov 2008
Posts: 8
Reputation: trinityavatar is an unknown quantity at this point 
Solved Threads: 0
trinityavatar trinityavatar is offline Offline
Newbie Poster

Re: Return value based upon visibility of form field?

 
0
  #11
Nov 20th, 2008
Thank you Essential and Drew for your suggestions.
I have a couple more questions for both of you.

Drew,
Thanks again!
I understand that your coding below would return a value of T/F on the checkbox:
document.FromName.checkBoxName.checked
What I'd like to figure out still is the following:
1) checkbox returns value of T/F
2) checkbox triggers an event as follows
• if True: return product (a*b) into TotalField
• if False: delete contents of TotalField
I've been able to reset contents of TotalField to 0.00 but when I attempt to return the product (a*b) to TotalField, it remains 0.00.

This code currently activates the "No" Checkbox and sets the TotalField to 0.00

var CollectionTotal = this.getField("CollectionTotal")
function resetField(name,value)
{
CollectionTotal.value = value;}

if (event.target.value == "No")
{
CollectionTotal.hidden = true
&& resetField('CollectionTotal','0.00')
}
else {
CollectionTotal.hidden = false
}
This code fails to return the product (a*b) into the TotalField when the "Yes" checkbox is True:

var CollectionTotal = this.getField("CollectionTotal")
function product(a,b)
{
return a*b;
}
if (event.target.value == "Yes")
{
CollectionTotal.hidden = false
&& document.write(product("CollectRate*NumPosters"))
}
else {
CollectionTotal.hidden = true
}


Essential,
Thanks so much for your generous consideration! However, at this point, the code you've included, appears to have the same issue I've been facing, namely the value generated by the calculation continues to appear in the total field whether or not the Field Value is hidden. Because I need to add up the selected totals of my client, this behavior results in an incorrect total.

Any further thoughts??

Thanks much for all your time!!

Best,
TrinityAvatar
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC