Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
|
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 19th, 2005, 10:52 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default javascript "stop" syntax - needs declared?

Code:
function unCheck(counter,type,cell)
{
    checked=false;
    for (x=0;x<counter;x++)
    {         
        eval("document.form."+type+""+x+".checked = false")
    }
    stop;
}
this code works, but i am getting a JS error:
"'stop' is undefined"

why is this?

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
 
Old August 19th, 2005, 03:59 PM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Three things, firstly my golden rule of JavaScript: NEVER USE EVAL.
Secondly what is stop meant to do? It is not a JavaScript statement and the function is about to return anyway so you don't need it. Thirdly why pass in cell to the function if you don't use it?
Code:
function unCheck(counter, type)
{
  for (x = 0; x < counter; x++)
  {
    document.form[type + x].checked = false;
  }
}
--

Joe (Microsoft MVP - XML)
 
Old August 22nd, 2005, 08:26 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

Code:
// Uncheck all boxes that have been previously checked
function unCheck(counter,type,cell)
{
    checked=false;
    for (x=0;x<counter;x++)
    {         
        eval("document.form."+type+""+x+".checked = false")
    }
    return false;
}
that works, why not use EVAL?

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
 
Old August 22nd, 2005, 08:46 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Basically it's an incredible resource hog and totally unnecessary. See here for the full story:

http://blogs.msdn.com/ericlippert/ar.../01/53329.aspx

--

Joe (Microsoft MVP - XML)
 
Old September 14th, 2005, 05:55 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

is there a quicker way to do this:
Code:
eval("df.pre"+i+".style.visibility = action");
www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt
 
Old September 14th, 2005, 06:01 AM
Friend of Wrox
 
Join Date: Jan 2005
Posts: 1,525
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to crmpicco Send a message via AIM to crmpicco Send a message via MSN to crmpicco Send a message via Yahoo to crmpicco
Default

Code:
function hideselect(action,uniquecount)
{
    //df = document.form

    for(i=0;i<uniquecount+1;i++)
    {
        // netfare1 drop-down menus to be hidden
        if(document.form.getElementByName("pre"+i+"")!=null)
        {
            eval("document.form.pre"+i+".style.visibility = action");
        }
        if(document.form.getElementByName("via1"+i+"")!=null)
        {
            eval("document.form.via1"+i+".style.visibility = action");
        }

        ...
        ...

        ...
I am getting a JS error at this line:

Code:
if(document.form.getElementByName("pre"+i+"")!=null)

Can anyone see the error?


www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
www.piccosmini.co.uk.tt
www.morton.uk.tt





Similar Threads
Thread Thread Starter Forum Replies Last Post
stop current javascript function using javascript sakthi Javascript 3 June 2nd, 2008 03:30 PM
Stop button won't stop loop JDShaffer Visual Basic 2008 Essentials 3 May 23rd, 2008 03:22 PM
Javascript return false won't stop post rstelma ASP.NET 1.0 and 1.1 Basics 9 March 16th, 2006 02:25 PM
FormsAuthentication not declared! Renu ASP.NET 1.0 and 1.1 Basics 2 October 6th, 2004 10:29 AM
Javascript Syntax Error Ben Horne Javascript 2 April 5th, 2004 09:38 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.