SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    document.form1.submit(); not working!

    I dont want to go into massive detail if not necessary. I have a validation script which ends with:

    document.form1.submit();

    but i'm getting the error 'object doesn't support this property or method'.

    This is on an 'update record' page, the same code works fine on the 'add record' page. The form is called form1. If I make the button which triggers this code a submit button it works fine (so its not the update code), even if I make the onclick event document.form1.submit(); it still errors

    any thoughts on what this might be?

    cheers

    monkey
    monkey - the rest is history

  2. #2
    SitePoint Enthusiast Tygatur's Avatar
    Join Date
    Apr 2006
    Location
    Germany
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure, that all <form> Tags are correctly closed and check spelling and case again !

    But why don't you post the source ? This way we have to make wild guesses about the error. It seems that you use the Internet Exploiter. Try the page with Firefox which has a far better JavaScript console than IE.
    to code or not to code ?
    that's too much of a question for a signature.

  3. #3
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there is no magic here! the function is:

    Code:
    function validate(){
    	var errors=""
    	if(!document.form1.start_date.value.match(/[0-3]{1}\d{1}\/[01]{1}\d{1}\/[12]{1}[09]{1}\d{2}/)){
    			errors='-Your date must be in the format dd/mm/yyyy\n';
    	}
    	if(document.form1.eventinfo.value==""){
    			errors=errors+'-You must select a meeting type\n';
    	}
    	if(document.form1.ev_misc1.value==""){
    			errors=errors+'-You must select a meeting venue\n';
    	}
    	if (errors!=""){
    		alert(errors)
    		return false;
    	}else{
    		document.form1.submit();
    	}
    }
    the form name is correct, all tags are complete. This workis fine on an identical page - the only diffenence being the create or upload script.

    Firefox says: Error: document.form1.submit is not a function
    Source File: http://mysite/mypage.asp?id=659
    Line: 28
    monkey - the rest is history

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like you have a form control named "submit". Change its name to something else and the problem should go away.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sounds like you have a form control named "submit".
    That's ALWAYS the problem, has happened a million times. It's a real pain to figure out the first time though.

  6. #6
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a cigar!!!

    I knew it would be something simple and I wouldn't need to post all the code!

    My button was original a submit button and was named as such!

    Never had this happen before, but now I know!!

    Cheers
    monkey - the rest is history

  7. #7
    SitePoint Enthusiast
    Join Date
    May 2006
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I know the thread is two years old, but I just had to register and let you know how pissed I was when I found out what the problem was with my script. Yep, the button I was using to submit was named submit. I've been working on building this registration form all friggin day. Most of it was troubleshooting regex's, and AJAX requests, but a good portion of the day was spent trying to find workarounds to submit my form AFTER receiving a response from the AJAX request. Arg. Thank you

  8. #8
    SitePoint Wizard boxhead's Avatar
    Join Date
    Feb 2004
    Location
    UK
    Posts
    1,040
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by avRedline
    I know the thread is two years old, but I just had to register and let you know how pissed I was when I found out what the problem was with my script. Yep, the button I was using to submit was named submit. I've been working on building this registration form all friggin day. Most of it was troubleshooting regex's, and AJAX requests, but a good portion of the day was spent trying to find workarounds to submit my form AFTER receiving a response from the AJAX request. Arg. Thank you
    Welcome the the forum! The place that has saved my keyboard from death many a time!!

    PS the thread is actually very recent - look at the top of the messages for the post dates.
    monkey - the rest is history


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •