Sid Childers
wading in the water Posts:25
|
03-14-2009 08:44 AM |
|
Good Morning All,
I have a form that needs to calculate subtotals and then a grand total. I've written the following client side event below for the amount 1 field. Unfortunately, when I try out the form, nothing is populated in the amount 1 field. Can someone review and let me know if I have errors in my script?
Thanks,
Sid
if ($(CampSelect)="Football Mega Camp Pratt KS June 10-13"
and $(Child1CampType)="Day Camp")
{
$(Child1Amount)=$(PrattDayPrice)
}
else
if ($(CampSelect)="Football Mega Camp Pratt KS June 10-13"
and $(Child1CampType)="Overnight Camp")
{
$(Child1Amount)=$(PrattOvernightPrice)
}
else
{
$(Child1Amount)="0"
} |
|
|
|
|
Chad Nash Posts:5260
|
03-14-2009 08:47 AM |
|
Hi. I think if an if statement in JavaScript it has to be == and not =. = is setting the value to something like val1=val2 and I think in an if statement it has to be something like if (val1 == val2) { etc.... I would download FireBug from FireFox, this always helps me as you can enter JavaScript right on the browser to test it easier. -Chad |
|
|
|
|
Sid Childers
wading in the water Posts:25
|
03-14-2009 08:55 AM |
|
Thanks Chad. I applied the == on all the instances of = and still does not work. Do I need to use ' instead of " for my text qualifiers? |
|
|
|
|
David To
river guide Posts:2719
|
03-14-2009 11:47 AM |
|
Try below (you're not supposed to apply == to all instances of =, only on the comparison). Additionally, put the client side script on both areas: in the module configuration on initial javascript and also in the textbox of the form. if ($(CampSelect)=="Football Mega Camp Pratt KS June 10-13" and $(Child1CampType)=="Day Camp") { $(Child1Amount)=$(PrattDayPrice) } else if ($(CampSelect)=="Football Mega Camp Pratt KS June 10-13" and $(Child1CampType)=="Overnight Camp") { $(Child1Amount)=$(PrattOvernightPrice) } else { $(Child1Amount)="0" } -- David |
|
|
|
|
Sid Childers
wading in the water Posts:25
|
03-15-2009 04:37 AM |
|
Hi David,
Thanks for your help on this one. Unfortunately, after following your directions, the Child 1 Amount field still does not have a value. Please let me know if you think of a different approach I should try.
Thanks,
Sid |
|
|
|
|
David To
river guide Posts:2719
|
03-15-2009 07:53 AM |
|
Sid, your $(CampSelect) and $(Child1CampType) shortnames, are they textbox, radio button box, listbox,combobox,etc? Also, $(PattDayPrice) and $(PrattOverNightPrice)?Need to be more specific since retrieving values may be different based on which field type you choose. -- David |
|
|
|
|
Sid Childers
wading in the water Posts:25
|
03-15-2009 12:10 PM |
|
David, $(CampSelect), $(Child1CampType), $(Child2CampType), $(Child3CampType) are all dropdown boxes. The rest are text boxes. All fields are being passed from previous form step via session variable. Is there a syntax difference in Javascript dependent on the field type? If so, please advise as to the syntax for a dropdown vs. a text box. Thanks so much for your help!! Sid |
|
|
|
|
David To
river guide Posts:2719
|
03-15-2009 07:58 PM |
|
Take $(Child1CampType) drop down box, what's your entries? For example, what is each of your Update Option Text / Update Option Value combination? Since you're retrieving them from session variable, can you create a textbox ($(texttest)), and in the client side event of the $(Child1CampType), set the following:
$(texttest) = $(Child1CampType). When you pick an entry from $(Child1CampType) combobox, it should populate the $(texttest) textbox. This will give you an indication what value you're actually getting. -- David |
|
|
|
|
Sid Childers
wading in the water Posts:25
|
03-16-2009 06:07 AM |
|
David,
I think I understand the issue. When I referenced the $(CampType) field, DF can't pickup the selected value. As such, can I simply use $(CampType).Selected ? If not, I'll use your workaround of creating text boxes for each combo box etc.
Thanks,
Sid |
|
|
|
|
David To
river guide Posts:2719
|
03-16-2009 06:35 AM |
|
DF can pick up values for drop down comboboxes (see Form 20 demos). I just want you to create a textbox as a test to see what values you are actually retrieving from the session from the previous form if it's passing correctly. It's a way to verify if the $(Child1CampType) actually contains values (Day Camp, Overnight Camp). -- David |
|
|
|
|
Sid Childers
wading in the water Posts:25
|
03-16-2009 07:29 PM |
|
Hi David,
I created $(texttest) on the step 3 form. In the client side event of Child1CampType, I used $(texttest)=$(Child1CampType). Unfortunately
$(texttest) is not being populated with the option value from $(Child1CampType). This is very strange behavior given that, in step 3, I'm placing read only text boxes containing fields passed along the session variable from the previous 2 steps, including $(Child1CampType).
Please let me know if there are any adjustments I should make, or any suggested alternatives of accomplishing the task of calculating a total based on numerous variables including camp type.
Thanks,
Sid |
|
|
|
|
David To
river guide Posts:2719
|
03-17-2009 07:02 AM |
|
Can you export the XML contents of your pages and send it to me at: david@datasprings.com and I'll try to spend some time checking it out? Or you can put them up on www.betasprings.com (username: host, password: dnnhost) and send me the URL link. -- David |
|
|
|
|
mmoney
wading in the water Posts:18
|
08-12-2010 01:41 PM |
|
Was there any resolution to this. I'm experiencing the same issue. I have a passed in field called $DSParam2 and I want the textbox $(AdType) to populate with the value from $DSParam2. I have reduce the complexity of my clientside event to this simple statement. $(AdType)=$(DSParam2) It doesn't seem to populate. I'm using 3.0.1. Thanks |
|
|
|
|
David To
river guide Posts:2719
|
08-12-2010 06:05 PM |
|
Is DSParam2 coming from a querystring variable? If that's the case, why do you need to set $(AdType) equal to it? Are you trying to set $(AdType) to be equal to some column in a database table through SQL binding? Can you provide more details concerning what you are trying to accomplish? -- David |
|
|
|
|
mmoney
wading in the water Posts:18
|
08-13-2010 03:24 PM |
|
Actually, I was using the above as a way of test if the values were being passed. What I'm really trying to do make a conditional statement that checks the income querystring variable and place specific text (based on the value passed) into a textbox. $(DSParam2) is the income querystring variable My current statement which doesn't work for some reason: If ($(DSParam2)==18) { $(AdType) = "Graphic" } Any help would be appreciated. |
|
|
|
|
Chad Nash Posts:5260
|
08-16-2010 01:35 PM |
|
Hi, Can you please... 1. Enable Debug Mode and copy/paste the exact client side event that is being executed. 2. I would install FireBug for FireFox (and then enable it, including enabling the 'Console' portion), this can also help to determine what the real error is and can be very helpful. Thanks, Chad |
|
|
|
|
mmoney
wading in the water Posts:18
|
08-16-2010 04:38 PM |
|
Hi, I enabled Debug Mode and get the following from the initial javascript: Initial Javascript:If($(DSParam2) == 18) { $(AdType)="Graphic" };; I user firebug and get this: If is not defined Very strange. Can you spot anything wrong with my syntax? Thanks |
|
|
|
|
Chad Nash Posts:5260
|
08-17-2010 03:17 PM |
|
Hi. If the DSParam tokens are used in initial javascript I think you would end up needing to: 1. Setup a hidden field with the short field name of DSParam2 2. either use a SQL Default to render the results or 3. use the feature 'retrieve from querystring value' under advanced field options. Also - Sometimes fields don't render properly because a performance enhancement unless they have client side events in them. So for example, go to 'client side events' for the hidden field I mentioned in step 1 and just add a few spaces or maybe something like 'var nothing;' within the client side event. Then the $(Token) will render properly. -Chad |
|
|
|
|