Great Ideas. Always Flowing.

We are not happy until you are happy. Client satisfaction guaranteed. Whatever your needs and requirements, we have the skills and resources for the job!

Quick login...


Or... now make it easy with Facebook Integration
Connect via Facebook



Top Sellers

Frustrated over the lack of customization for your user's registration fields? Dynamically setup your DNN Portal with custom registration fields, layout, questions, and other core integration options......

Ultra Video Gallery is a brother product of Ultra Media Gallery, UVG allows you to upload videos in various format and automatically encode them to flv or H264 format, you also can add videos from internet or record live videos from your webcam.

Build high performance, completely customizable data-entry forms and views driven by your DNN and external databases. New built-in tools make it a snap to quickly create data entry forms, data views, and even database tables. Plus, add your own HTML, CSS, Javascript, SQL commands, stored procedures,

The most advanced DotNetNuke shopping cart on the planet. Easy to use e-Commerce, Secure Shopping Cart Software and SEO friendly. B2C / B2B Ecommerce Sites.

One stop solution for events calendar and events registration! FREE DOWNLOAD is available now!

Javascript if else if statement in client side event
Last Post 08-17-2010 03:17 PM by Chad Nash. 17 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Sid ChildersUser is Offline
wading in the water
wading in the water
Posts:25
Avatar

--
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 NashUser is Offline
    Posts:5260
    Avatar

    --
    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 ChildersUser is Offline
    wading in the water
    wading in the water
    Posts:25
    Avatar

    --
    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 ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    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 ChildersUser is Offline
    wading in the water
    wading in the water
    Posts:25
    Avatar

    --
    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 ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    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 ChildersUser is Offline
    wading in the water
    wading in the water
    Posts:25
    Avatar

    --
    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 ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    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 ChildersUser is Offline
    wading in the water
    wading in the water
    Posts:25
    Avatar

    --
    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 ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    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 ChildersUser is Offline
    wading in the water
    wading in the water
    Posts:25
    Avatar

    --
    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 ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    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
    mmoneyUser is Offline
    wading in the water
    wading in the water
    Posts:18
    Avatar

    --
    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 ToUser is Offline
    river guide
    river guide
    Posts:2719
    Avatar

    --
    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
    mmoneyUser is Offline
    wading in the water
    wading in the water
    Posts:18
    Avatar

    --
    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 NashUser is Offline
    Posts:5260
    Avatar

    --
    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
    mmoneyUser is Offline
    wading in the water
    wading in the water
    Posts:18
    Avatar

    --
    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 NashUser is Offline
    Posts:5260
    Avatar

    --
    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
    You are not authorized to post a reply.


     
     

    Join our mailing list...

    Get current news and events the easy way
    Subscribe Me

    Recent Blogs...

     
    Copyright 2005 - 2011 by Data Springs, Inc.
     
  • film izle
  • 720 izle
  • film
  • sinema izle
  • film makinesi
  • T�rk�e dublaj film
  • film izle
  • film izle
  • baglan film izle
  • sinema izle
  • 1080 film izle
  • film mercegi