I need to create a form on the fly

Discussion in 'Javascript' started by Phil Powell, May 3, 2006.

  1. Phil Powell

    Phil Powell Guest

    Requirement is to refresh a page in the form of a continual form
    submittal (for server-side validation and action)

    Here is the Javascript I came up with that I thought would do that:

    <script type="text/javascript">
    function generateForm() {
    document.forms[0].elements[0].name = 'username';
    document.forms[0].elements[0].type = 'hidden';
    document.forms[0].elements[0].value = 'ppowell'
    document.forms[0].elements[1].name = 'hasSubmittedLogin';
    document.forms[0].elements[1].type = 'hidden';
    document.forms[0].elements[1].value = '1'
    document.forms[0].elements[2].name = 'id';
    document.forms[0].elements[2].type = 'hidden';
    document.forms[0].elements[2].value = '144'
    document.forms[0].elements[3].name = 'submit';
    document.forms[0].elements[3].type = 'hidden';
    document.forms[0].elements[3].value = 'Login to view required forms'
    document.forms[0].action = '/student/formlist.php';
    document.forms[0].submit();
    }

    self.setTimeout('generateForm', 8000);
    </script>

    I keep getting the same error in both Firefox (Linux) and Konqueror:

    document.forms[0] has no properties

    Is there a way to refresh a page automatically causing continual form
    auto-submit, required for continual server-side activity?

    Thanx
    Phil
     
    Phil Powell, May 3, 2006
    #1
    1. Advertising

  2. Phil Powell

    Lee Guest

    Phil Powell said:
    >
    >Requirement is to refresh a page in the form of a continual form
    >submittal (for server-side validation and action)
    >
    >Here is the Javascript I came up with that I thought would do that:
    >
    ><script type="text/javascript">
    >function generateForm() {
    > document.forms[0].elements[0].name = 'username';
    > document.forms[0].elements[0].type = 'hidden';
    > document.forms[0].elements[0].value = 'ppowell'
    > document.forms[0].elements[1].name = 'hasSubmittedLogin';
    > document.forms[0].elements[1].type = 'hidden';
    > document.forms[0].elements[1].value = '1'
    > document.forms[0].elements[2].name = 'id';
    > document.forms[0].elements[2].type = 'hidden';
    > document.forms[0].elements[2].value = '144'
    > document.forms[0].elements[3].name = 'submit';
    > document.forms[0].elements[3].type = 'hidden';
    > document.forms[0].elements[3].value = 'Login to view required forms'
    > document.forms[0].action = '/student/formlist.php';
    > document.forms[0].submit();
    > }
    >
    > self.setTimeout('generateForm', 8000);
    ></script>
    >
    >I keep getting the same error in both Firefox (Linux) and Konqueror:
    >
    >document.forms[0] has no properties
    >
    >Is there a way to refresh a page automatically causing continual form
    >auto-submit, required for continual server-side activity?


    When you submit a form, the server sends back a new page.
    Just have it send back the form, instead of creating it in script.


    --
     
    Lee, May 3, 2006
    #2
    1. Advertising

  3. Phil Powell

    Phil Powell Guest

    Lee wrote:
    > Phil Powell said:
    > >
    > >Requirement is to refresh a page in the form of a continual form
    > >submittal (for server-side validation and action)
    > >
    > >Here is the Javascript I came up with that I thought would do that:
    > >
    > ><script type="text/javascript">
    > >function generateForm() {
    > > document.forms[0].elements[0].name = 'username';
    > > document.forms[0].elements[0].type = 'hidden';
    > > document.forms[0].elements[0].value = 'ppowell'
    > > document.forms[0].elements[1].name = 'hasSubmittedLogin';
    > > document.forms[0].elements[1].type = 'hidden';
    > > document.forms[0].elements[1].value = '1'
    > > document.forms[0].elements[2].name = 'id';
    > > document.forms[0].elements[2].type = 'hidden';
    > > document.forms[0].elements[2].value = '144'
    > > document.forms[0].elements[3].name = 'submit';
    > > document.forms[0].elements[3].type = 'hidden';
    > > document.forms[0].elements[3].value = 'Login to view required forms'
    > > document.forms[0].action = '/student/formlist.php';
    > > document.forms[0].submit();
    > > }
    > >
    > > self.setTimeout('generateForm', 8000);
    > ></script>
    > >
    > >I keep getting the same error in both Firefox (Linux) and Konqueror:
    > >
    > >document.forms[0] has no properties
    > >
    > >Is there a way to refresh a page automatically causing continual form
    > >auto-submit, required for continual server-side activity?

    >
    > When you submit a form, the server sends back a new page.
    > Just have it send back the form, instead of creating it in script.
    >
    >
    > --


    This is the closest I could get to what you were talking about:

    <form name="manualResetForm" method="POST"
    action="/student/formlist.php">
    <input type="hidden" name="username" value="ppowell">
    <input type="hidden" name="hasSubmittedLogin" value="1">

    <input type="hidden" name="id" value="144">
    <input type="hidden" name="submit" value="Login to view required
    forms">

    <script type="text/javascript">
    self.setTimeout('document.manualResetForm.submit', 8000);
    </script>
    <noscript>

    Due to security constraints, once you click to view/download any of the
    above-referenced forms, you must <input type="submit" name="submit"
    value="click here"> before you are able to view/download any other
    above-referenced form<br><br>
    </noscript>

    This never auto-submits the form and thus refreshes the page via FORM
    post.

    Phil
     
    Phil Powell, May 3, 2006
    #3
  4. Phil Powell

    Phil Powell Guest

    Phil Powell wrote:
    > Lee wrote:
    > > Phil Powell said:
    > > >
    > > >Requirement is to refresh a page in the form of a continual form
    > > >submittal (for server-side validation and action)
    > > >
    > > >Here is the Javascript I came up with that I thought would do that:
    > > >
    > > ><script type="text/javascript">
    > > >function generateForm() {
    > > > document.forms[0].elements[0].name = 'username';
    > > > document.forms[0].elements[0].type = 'hidden';
    > > > document.forms[0].elements[0].value = 'ppowell'
    > > > document.forms[0].elements[1].name = 'hasSubmittedLogin';
    > > > document.forms[0].elements[1].type = 'hidden';
    > > > document.forms[0].elements[1].value = '1'
    > > > document.forms[0].elements[2].name = 'id';
    > > > document.forms[0].elements[2].type = 'hidden';
    > > > document.forms[0].elements[2].value = '144'
    > > > document.forms[0].elements[3].name = 'submit';
    > > > document.forms[0].elements[3].type = 'hidden';
    > > > document.forms[0].elements[3].value = 'Login to view required forms'
    > > > document.forms[0].action = '/student/formlist.php';
    > > > document.forms[0].submit();
    > > > }
    > > >
    > > > self.setTimeout('generateForm', 8000);
    > > ></script>
    > > >
    > > >I keep getting the same error in both Firefox (Linux) and Konqueror:
    > > >
    > > >document.forms[0] has no properties
    > > >
    > > >Is there a way to refresh a page automatically causing continual form
    > > >auto-submit, required for continual server-side activity?

    > >
    > > When you submit a form, the server sends back a new page.
    > > Just have it send back the form, instead of creating it in script.
    > >
    > >
    > > --

    >
    > This is the closest I could get to what you were talking about:
    >
    > <form name="manualResetForm" method="POST"
    > action="/student/formlist.php">
    > <input type="hidden" name="username" value="ppowell">
    > <input type="hidden" name="hasSubmittedLogin" value="1">
    >
    > <input type="hidden" name="id" value="144">
    > <input type="hidden" name="submit" value="Login to view required
    > forms">
    >
    > <script type="text/javascript">
    > self.setTimeout('document.manualResetForm.submit', 8000);
    > </script>
    > <noscript>
    >
    > Due to security constraints, once you click to view/download any of the
    > above-referenced forms, you must <input type="submit" name="submit"
    > value="click here"> before you are able to view/download any other
    > above-referenced form<br><br>
    > </noscript>
    >
    > This never auto-submits the form and thus refreshes the page via FORM
    > post.
    >
    > Phil


    I managed to redesign it, however, nothing happens upon <body
    onLoad="manualReset()">

    <script type="text/javascript">
    <!--

    function manualReset() {
    self.setTimeout('document.manualResetForm.submit', 800);
    }

    //-->
    </script>

    However, absolutely nothing happens and I can't seem to figure out why
    at this point.

    Phil
     
    Phil Powell, May 4, 2006
    #4
  5. Phil Powell

    ASM Guest

    Phil Powell a écrit :
    > Lee wrote:
    >
    >>Phil Powell said:
    >>>
    >>>I keep getting the same error in both Firefox (Linux) and Konqueror:
    >>>
    >>>document.forms[0] has no properties


    did your page have a form (even empty) ?

    >>>Is there a way to refresh a page automatically causing continual form
    >>>auto-submit, required for continual server-side activity?

    >>
    >>When you submit a form, the server sends back a new page.
    >>Just have it send back the form, instead of creating it in script.
    >>
    >>
    >>--

    >
    >
    > This is the closest I could get to what you were talking about:
    >
    > <form name="manualResetForm" method="POST"
    > action="/student/formlist.php">
    > <input type="hidden" name="username" value="ppowell">
    > <input type="hidden" name="hasSubmittedLogin" value="1">
    >
    > <input type="hidden" name="id" value="144">
    > <input type="hidden" name="submit" value="Login to view required
    > forms">
    >
    > <script type="text/javascript">
    > self.setTimeout('document.manualResetForm.submit', 8000);


    setTimeout('document.forms[\'manualResetForm\'].submit()', 8000);

    > This never auto-submits the form and thus refreshes the page via FORM
    > post.


    Yes, that would have to submit to your formlist.php

    --
    Stephane Moriaux et son [moins] vieux Mac
     
    ASM, May 4, 2006
    #5
  6. Phil Powell

    Phil Powell Guest

    ASM wrote:
    > Phil Powell a écrit :
    > > Lee wrote:
    > >
    > >>Phil Powell said:
    > >>>
    > >>>I keep getting the same error in both Firefox (Linux) and Konqueror:
    > >>>
    > >>>document.forms[0] has no properties

    >
    > did your page have a form (even empty) ?
    >


    Yes. The original as well as the generated formlist.php has a form at
    all times, verified via alert(document.manualResetForm);


    > >>>Is there a way to refresh a page automatically causing continual form
    > >>>auto-submit, required for continual server-side activity?
    > >>
    > >>When you submit a form, the server sends back a new page.
    > >>Just have it send back the form, instead of creating it in script.
    > >>
    > >>
    > >>--

    > >
    > >
    > > This is the closest I could get to what you were talking about:
    > >
    > > <form name="manualResetForm" method="POST"
    > > action="/student/formlist.php">
    > > <input type="hidden" name="username" value="ppowell">
    > > <input type="hidden" name="hasSubmittedLogin" value="1">
    > >
    > > <input type="hidden" name="id" value="144">
    > > <input type="hidden" name="submit" value="Login to view required
    > > forms">
    > >
    > > <script type="text/javascript">
    > > self.setTimeout('document.manualResetForm.submit', 8000);

    >
    > setTimeout('document.forms[\'manualResetForm\'].submit()', 8000);
    >
    > > This never auto-submits the form and thus refreshes the page via FORM
    > > post.

    >
    > Yes, that would have to submit to your formlist.php


    It doesn't do that, and it's supposed to do that.

    CODE:

    <script type="text/javascript">
    function autosubmit() {
    alert(document.forms[0]);
    document.manualResetForm.submit();
    }

    function manualReset() {
    self.setTimeout('autosubmit', 800);
    }
    </script>
    >


    Nothing happens, no alert is spawned, nothing at all. No errors of any
    kind.

    Phil

    > --
    > Stephane Moriaux et son [moins] vieux Mac
     
    Phil Powell, May 4, 2006
    #6
  7. Phil Powell

    Phil Powell Guest

    Phil Powell wrote:
    > ASM wrote:
    > > Phil Powell a écrit :
    > > > Lee wrote:
    > > >
    > > >>Phil Powell said:
    > > >>>
    > > >>>I keep getting the same error in both Firefox (Linux) and Konqueror:
    > > >>>
    > > >>>document.forms[0] has no properties

    > >
    > > did your page have a form (even empty) ?
    > >

    >
    > Yes. The original as well as the generated formlist.php has a form at
    > all times, verified via alert(document.manualResetForm);
    >
    >
    > > >>>Is there a way to refresh a page automatically causing continual form
    > > >>>auto-submit, required for continual server-side activity?
    > > >>
    > > >>When you submit a form, the server sends back a new page.
    > > >>Just have it send back the form, instead of creating it in script.
    > > >>
    > > >>
    > > >>--
    > > >
    > > >
    > > > This is the closest I could get to what you were talking about:
    > > >
    > > > <form name="manualResetForm" method="POST"
    > > > action="/student/formlist.php">
    > > > <input type="hidden" name="username" value="ppowell">
    > > > <input type="hidden" name="hasSubmittedLogin" value="1">
    > > >
    > > > <input type="hidden" name="id" value="144">
    > > > <input type="hidden" name="submit" value="Login to view required
    > > > forms">
    > > >
    > > > <script type="text/javascript">
    > > > self.setTimeout('document.manualResetForm.submit', 8000);

    > >
    > > setTimeout('document.forms[\'manualResetForm\'].submit()', 8000);
    > >
    > > > This never auto-submits the form and thus refreshes the page via FORM
    > > > post.

    > >
    > > Yes, that would have to submit to your formlist.php

    >
    > It doesn't do that, and it's supposed to do that.
    >
    > CODE:
    >
    > <script type="text/javascript">
    > function autosubmit() {
    > alert(document.forms[0]);
    > document.manualResetForm.submit();
    > }
    >
    > function manualReset() {
    > self.setTimeout('autosubmit', 800);
    > }
    > </script>
    > >

    >
    > Nothing happens, no alert is spawned, nothing at all. No errors of any
    > kind.
    >
    > Phil
    >
    > > --
    > > Stephane Moriaux et son [moins] vieux Mac



    GOT IT!

    <script type="text/javascript">
    <!--

    function autosubmit() {
    document.manualResetForm.submit();
    }

    function manualReset() {
    self.setTimeout('autosubmit()', 15000);
    }

    //-->
    </script>

    Basically I just plain guessed it as all of the Google references I
    found apparently were syntactically wrong for what I needed to do!

    Phil
     
    Phil Powell, May 4, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rick Spiewak

    Re: Create thumbnails on the fly

    Rick Spiewak, Jul 24, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    496
    David W. Simmonds
    Jul 25, 2003
  2. Cowboy \(Gregory A. Beamer\)

    Re: programatically create controls on the fly

    Cowboy \(Gregory A. Beamer\), Jul 31, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    437
    Cowboy \(Gregory A. Beamer\)
    Jul 31, 2003
  3. shapper
    Replies:
    5
    Views:
    416
    Karl Seguin
    Nov 30, 2006
  4. kj

    Can I create a form on the fly?

    kj, Aug 4, 2004, in forum: Javascript
    Replies:
    1
    Views:
    138
  5. Brian

    Fly outmenu on the fly

    Brian, Apr 8, 2005, in forum: Javascript
    Replies:
    0
    Views:
    118
    Brian
    Apr 8, 2005
Loading...

Share This Page