SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Addict chartahir's Avatar
    Join Date
    Oct 2006
    Location
    Karachi, Pakistan
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Automatic form submission

    I'm trying to submit a form when the count down timer reaches zero, it works fine on sample page, but when I integrate it with the real page i got the error: "Object Doesn't support this property or method."

    There are two options to submit the form,
    automatically when the timer reaches zero,
    and manual submission.

    On both events i call a function :

    function newf() {
    document.quest.name.value = "Test";
    document.quest.submit();
    }

    but i'm getting error.

    Help Plz,
    chartahir

  2. #2
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Could you please post the whole code that you have of JavaScript so that we can see how the cont down is being? Rest the submit code seems OK.
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  3. #3
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you name a submit button in the form "submit"? If so, change its name to something else.
    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.

  4. #4
    SitePoint Addict chartahir's Avatar
    Join Date
    Oct 2006
    Location
    Karachi, Pakistan
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The timer function is called on page load, the timer start, but when it reaches zero, form is not submitted.

    The counter value is stored in cookie,becasue if the user refreshes the counter must not have to start from begining.

    Here is the Code.
    Code:
    <script language="javascript" type="text/javascript">
    
    
    function timer()	{
    var timer = 0; 
    
    
    if (getc = getcookie('timer'))	{
    timer = getc;
    }
    else {
    document.cookie = "timer="+15;
    document.getElementById("txtHint").innerHTML=15;
    timer = 15;
    }
    
    				
    var name;
    
    timer = timer - 1;
    
    document.cookie = "timer="+timer;
    document.getElementById("txtHint").innerHTML= timer;
    //document.test.time.value = timer;
    
    
    
    if (timer == 0)	{
    //timer = 180;
    document.cookie = "timer="+15;
    
    //name = document.test.name.value;
    //name++;
    //document.test.name.value = name;
    
    newf();
    
    //document.test.Submit();
    }//else
    //document.test.time.value = timer;
    
    //alert(timer);
    
    setTimeout("timer()", 1000);
    }
    
    // This function is used to submit the form
    function newf()	{
    document.quest.name.value = "Test";
    document.cookie = "timer="+15;
    document.quest.submit();
    }
    
    
    
    function getcookie(cookiename) {
     var cookiestring=""+document.cookie;
     var index1=cookiestring.indexOf(cookiename);
     if (index1==-1 || cookiename=="") return ""; 
     var index2=cookiestring.indexOf(';',index1);
     if (index2==-1) index2=cookiestring.length; 
     return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
    }
    
    </script>
    chartahir

  5. #5
    SitePoint Addict chartahir's Avatar
    Join Date
    Oct 2006
    Location
    Karachi, Pakistan
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i've already changed the submit button !
    chartahir

  6. #6
    SitePoint Guru
    Join Date
    Apr 2007
    Posts
    813
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I doubt this the one that will affect the overall process, but I have something that I am not sure
    Code:
    setTimeout("timer()", 1000);  // shouldn't that be
    setTimeout(timer, 1000);
    and you have variable timer, and you have a function call timer also, would that be confusing ....

  7. #7
    SitePoint Addict chartahir's Avatar
    Join Date
    Oct 2006
    Location
    Karachi, Pakistan
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    on a sample page i created it works fine, but when i ingtegrate it with the real form it causes error, for first time the timer starts and works fine but when it reaches to "document.quest.submit()" i got an error ""Object Doesn't support this property or method."
    "

    ????
    chartahir

  8. #8
    SitePoint Addict chartahir's Avatar
    Join Date
    Oct 2006
    Location
    Karachi, Pakistan
    Posts
    253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Kravvitz you really helped me out, when doing integration i've changed the button value only,but the name of button left unchanged.

    Thanks again.
    chartahir


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
  •