Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...How to get basic javascript working?How to get basic javascript working?
Previous
 
Next
New Post
1/23/2009 3:21 AM
 

Thanks again mamlin for being so prompt!

I have expanding on the code, but as a non-developer learning how this works - first time I've touched javascript.  It's the same code but like you mentioned, using a different number of checkbox collections (do you read minds?)

http://old.privilegesgroup.co.uk/YourLifeEvaluator.html

That gives a good idea of what I'm looking to do, though I intend to make it a little more dynamic by actually display and storing results (learning to use XMod Pro).

Just taking it a step at a time but the form thing has already presented my first hurdle.  I did try changing to div, using the form =, taking it out and so on... but just not getting it working. Betting it's something small I just don't understand yet - but willing to learn!

Thanks

David

PS. I like your blog. Some useful things in there which I'm reading about now (AdvancedDataGrids etc)

 
New Post
1/24/2009 5:23 AM
Accepted Answer 

David-
XMOD is a great module -- I use it all the time.  It has its quirks but overall is a rock-solid performer.  I actually have a blog post dealing with tips for 508 compliance in XMOD forms on my "to-do" list ("languishing on my to-do list" is a bit more accurate).

Below are changes to the sample HTML page you linked that will let you get rid of your "form" tag. This is not the most versatile (or code efficient) way of doing things but it will get you going with relatively small changes to the flow of your existing sample code.

Good luck with the XMOD and JavaScript.  While you're still getting your feet wet in JS, remember that W3SCHOOLS is your friend.

Cheers! 
-mamlin
 
 
Changes to sample HTML at:  http://old.privilegesgroup.co.uk/YourLifeEvaluator.html

Change 1:  Replace everything inside your script tags with:

function anyCheck()
{
var CareerTotal = 0;
// Get collection of elements with name "Career"
var CareerCol = document.getElementsByName('Career');

var FinancesTotal = 0;
var FinancesCol = document.getElementsByName('Finances');

var MyTimeTotal = 0;
var MyTimeCol = document.getElementsByName('MyTime');

var HealthTotal = 0;
var HealthCol = document.getElementsByName('Health');

var RelationshipsTotal = 0;
var RelationshipsCol = document.getElementsByName('Relationships');

var GrowthTotal = 0;
var GrowthCol = document.getElementsByName('Growth');

var TotalScore = 0;

for (var idx = 0; idx < CareerCol.length; idx++) {
if (eval("CareerCol[" + idx + "].checked") == true) {
    CareerTotal += 1;
   }
}

for (var idx = 0; idx < FinancesCol.length; idx++) {
if (eval("FinancesCol[" + idx + "].checked") == true) {
    FinancesTotal += 1;
   }
}

for (var idx = 0; idx < MyTimeCol.length; idx++) {
if (eval("MyTimeCol[" + idx + "].checked") == true) {
    MyTimeTotal += 1;
   }
}

for (var idx = 0; idx < HealthCol.length; idx++) {
if (eval("HealthCol[" + idx + "].checked") == true) {
    HealthTotal += 1;
   }
}

for (var idx = 0; idx < RelationshipsCol.length; idx++) {
if (eval("RelationshipsCol[" + idx + "].checked") == true) {
    RelationshipsTotal += 1;
   }
}

for (var idx = 0; idx < GrowthCol.length; idx++) {
if (eval("GrowthCol[" + idx + "].checked") == true) {
    GrowthTotal += 1;
   }
}

TotalScore = CareerTotal + FinancesTotal + MyTimeTotal + HealthTotal + RelationshipsTotal + GrowthTotal

Career: " + CareerTotal + ", Finances: " + FinancesTotal + ", My Time: " + MyTimeTotal + ", Health: " + HealthTotal +

", Relationships: " + RelationshipsTotal + ", Growth: " + GrowthTotal + ", TOTAL: " + TotalScore);
}

 
Step 2:  Changes to HTML
 
Change your "form" tags to plain "div" with nothing else inside (no attributes).  You don't really need the "div" for this example to work but it's good practice to enclose things inside a root container element (see general
XHTML guidelines).  You page would normally be within "HTML" tags as the root container but I understand your example is to be placed within a DNN module (Text/HTML module or an XMOD form) so you don't want "HTML", "BODY" or "form" tags included in your code.
 
 


esmamlin atxgeek.me
 
New Post
1/24/2009 6:29 AM
 

Hi mamlin

Thank you very much for pointing me in the right direction, and sorting through that for me. As you know, the html file I had really was the bare basics to be used within a text/html module.  I just threw it online so you (or others) could see it working and what I was hoping to achieve (as the first step).

I'll also take a good look at the w3schools. I had started looking through the tutorials at WebReference as I realise I need to get a better understand and learn some javascript if I'm going to make proper use of it.

Looking forward to getting stuck into XMod Pro. Kelly does seem very proactive with it, detailed responses and obviously tries to help everyone and improve it constantly.  It's great to hear others are happy with this, so I feel I am on the right path with it too.

Many thanks

David

 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...How to get basic javascript working?How to get basic javascript working?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out