Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 30th, 2005, 07:36 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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 null error

I have a form called 'fexp' and two hidden fields called 'multileg' and 'submitcounter', and they both have values of 'true' to start with. I have a Javascript function as per below:

Code:
function submitvalues()
{
if ((document.fexp.multileg.value == true)&&(document.fexp.submitcounter.value == true))
    {
        document.fexp.submit();
        document.fexp.multileg.value == false;
        document.fexp.submitcounter.value == false;
    }
}
I call it in the <body> tag:
Code:
<body bgcolor="#f5f5f5" leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 onload="setframe();document.fexp.depapt.focus();return submitvalues();">
But i keep get this error:

document.fexp.multileg.value is null or not a object.

However, it is DEFINATELY there:

Code:
<input type="hidden" name="multileg" value="<%=multileg%>">
                  <input type="hidden" name="submitcounter" value="<%=submitcounter%>">

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
__________________
_______________________
Ayrshire Minis - a Mini E-Community
http://www.ayrshireminis.com
http://www.crmpicco.co.uk
Reply With Quote
  #2 (permalink)  
Old March 30th, 2005, 08:03 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Can you show the whole form, maybe you have two elements with the same name?
As a side issue:
Code:
if(document.fexp.multileg.value == true)
is not safe, the value property in this case is a string so:
Code:
if(document.fexp.multileg.value == "true")
The other debug test is to turn them, temporarily, into text elements and see if you can focus on them without submitting.

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old March 30th, 2005, 09:17 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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:
if(document.fexp.multileg.value == "true")
That was one of my problems, thank you.

This code changes the values of the txt boxes but it just keeps submitting the form continuously:

Code:
function submitvalues()
{
if ((document.fexp.multileg.value == "true")&&(document.fexp.submitcounter.value == "true"))
    {
        document.fexp.submit();
        document.fexp.multileg.value == "false";
        document.fexp.submitcounter.value == "false";
    }
}
how can i do it only once???

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
Reply With Quote
  #4 (permalink)  
Old March 30th, 2005, 09:18 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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

* how can i submit the form only ONCE?

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
Reply With Quote
  #5 (permalink)  
Old March 30th, 2005, 09:32 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well as both items need to be true before you submit set them to false immediately, otherwise the form submits before you change them:
Code:
if ((document.fexp.multileg.value == "true")&&(document.fexp.submitcounter.value == "true"))
    {
        document.fexp.multileg.value == "false";
        document.fexp.submitcounter.value == "false";
        document.fexp.submit();

    }
Seems odd that you need to do this at all. Why load a page and then submit immediately?

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #6 (permalink)  
Old March 30th, 2005, 09:48 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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 submitvalues()
{
if ((document.fexp.multileg.value == "true")&&(document.fexp.submitcounter.value == "true"))
    {
        document.fexp.multileg.value == "false"
        document.fexp.submitcounter.value == "false"
        document.fexp.submit();
    }
}
That does the same, continuous submission of form.

Code:
<body bgcolor="#f5f5f5" leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 onload="setframe();submitvalues();">
www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
Reply With Quote
  #7 (permalink)  
Old March 30th, 2005, 09:49 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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 way to submit the form just once? a counter or something?

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
Reply With Quote
  #8 (permalink)  
Old March 30th, 2005, 09:56 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well you have to set to false on the server, modify "multileg" after you have submitted, then you can delete the two lines before the submission. As I said it's a weird way of doing something. What does the form do on the server when it's submitted?

--

Joe (Microsoft MVP - XML)
Reply With Quote
  #9 (permalink)  
Old March 30th, 2005, 09:58 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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

how do i do this?

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
Reply With Quote
  #10 (permalink)  
Old March 30th, 2005, 09:59 AM
Friend of Wrox
Points: 8,019, Level: 38
Points: 8,019, Level: 38 Points: 8,019, Level: 38 Points: 8,019, Level: 38
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2005
Location: Mauchline, East Ayrshire, Scotland
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

the form submits to itself

www.crmpicco.co.uk
www.crmpicco.co.uk.tt
www.milklemonadechocolate.uk.tt
www.griswolds.uk.tt
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
display Null or Not an object error kishy449 Classic ASP Professional 1 September 4th, 2007 01:21 PM
Error: (variable) is null or not an object alisonchase JSP Basics 1 February 14th, 2005 07:14 AM
Error inserting NULL value from form saturdave ASP.NET 1.x and 2.0 Application Design 2 January 12th, 2005 12:47 PM
null exception error abhit_kumar JSP Basics 4 January 5th, 2005 05:26 PM
Error: 'style.display' is null or not an object Adam H-W Javascript 4 April 22nd, 2004 08:45 AM



All times are GMT -4. The time now is 12:01 AM.


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