question about post/get

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Winter

    #16
    Re: question about post/get

    On Thu, 18 Nov 2004 16:49:14 +1000, q2005 <q2005@tpg.com. au> wrote:

    [snip]
    [color=blue]
    > 1. Why on open new window needs to return true while on _self doesn't
    > need?[/color]

    Neither needs to return true, so don't worry about it.
    [color=blue]
    > 2. Since on handle_submit() , it will change the action, is the "action="
    > in the form a dummy one? Or it should have?[/color]

    I should certainly hope it's only a dummy. Making a form submission
    dependant upon Javascript is moronic.
    [color=blue]
    > 3. How can the action can be executed either on the new page or the
    > original page? Does it depend on target?[/color]

    Not sure what you're asking there.

    Anyway, the answer to your previous question is a simple one. As I said,
    look at the FAQ (<URL:http://jibbering.com/faq/>). The answer is there.

    [snip]

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.

    Comment

    • RobB

      #17
      Re: question about post/get

      "q2005" <q2005@tpg.com. au> wrote in message news:<419c45eb@ dnews.tpgi.com. au>...[color=blue]
      > Thanks RobB.
      > On this example, when open in a new window, sometimes it won't work. The IE
      > browser said "this page can not displayed". The most times, it works.
      > questions:
      > 1. Why on open new window needs to return true while on _self doesn't need?
      > 2. Since on handle_submit() , it will change the action, is the "action=" in
      > the form a dummy one? Or it should have?
      > 3. How can the action can be executed either on the new page or the original
      > page? Does it depend on target?
      >
      > Jack
      >[color=green]
      > >
      > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
      > > <html xmlns="http://www/w3/org/TR/xhtml1">
      > > <head>
      > > <title>untitled </title>
      > > <script type="text/javascript">
      > > //<![CDATA[
      > >
      > > function dummy(v)
      > > {
      > > return '<h4>' + v + '</h4>';
      > > }
      > >
      > > function handle_submit(f )
      > > {
      > > if (document.getEl ementById('w'). checked)
      > > {
      > > f.target = 'formpop';
      > > f.action = 'javascript:ope ner.dummy(opene r.document.form s[0].foo.value)';
      > > //demo only
      > > var w = 300;
      > > var h = 180;
      > > var l = (screen.availWi dth - w) * .5;
      > > var t = (screen.availHe ight - h) * .5;
      > > var features =[/color]
      > 'width='+w+',he ight='+h+',left ='+l+',top='+t+ ',status,scroll bars,resizable' ;[color=green]
      > > formpop = open('about:bla nk', 'formpop', features);
      > > formpop.focus() ;
      > > return true;
      > > }
      > > else
      > > {
      > > f.target = '_self';
      > > f.action = 'javascript:dum my(document.for ms[0].foo.value)'; //ditto
      > > }
      > > }
      > >
      > > // ]]>
      > > </script>
      > > </head>
      > > <body>
      > > <form action="javascr ipt:dummy(docum ent.forms[0].foo.value)"
      > > onsubmit="retur n handle_submit(t his)">
      > > <input id="w" type="checkbox" /> open in new window?<br /><br />
      > > <input type="text" name="foo" value="...enter something here" />
      > > <input type="submit" value="done" />
      > > </form>
      > > </body>
      > > </html>[/color][/color]

      [color=blue]
      > 1. Why on open new window needs to return true while on _self doesn't need?[/color]

      It's not specifically necessary for either, as returning anything but
      false will have no effect. Should have moved that to just before the
      closing bracket, but it was trivial so I missed it.

      [color=blue]
      > 2. Since on handle_submit() , it will change the action, is the "action=" in[/color]
      the form a dummy one? Or it should have?

      Yes. btw DEMO ONLY means 'remove this for real-world use'. Just wanted
      to avoid posting a sample form page.
      [color=blue]
      > 3. How can the action can be executed either on the new page or the original[/color]
      page? Does it depend on target?

      You'll need to try that one again.


      function handle_submit(f )
      {
      if (document.getEl ementById('w'). checked)
      {
      f.target = 'formpop';
      var w = 300;
      var h = 180;
      var l = (screen.availWi dth - w) * .5;
      var t = (screen.availHe ight - h) * .5;
      var features = 'width='+w+',he ight='+h+',left ='+l+',top='+t+ ',status,scroll bars,resizable' ;
      formpop = open('about:bla nk', 'formpop', features);
      formpop.focus() ;
      }
      else f.target = '_self';
      return true;
      }

      // ]]>
      </script>
      </head>
      <body>
      <form action="[whatever]"
      onsubmit="retur n handle_submit(t his)">

      Comment

      • lawrence

        #18
        Re: question about post/get

        "Ivo" <no@thank.you > wrote in message news:<41998761$ 0$45939$a344fe9 8@news.wanadoo. nl>...[color=blue]
        >s, Ivo. It's so helpful. By the way, after summit, how do I delete
        > the[color=green]
        > > form object? Thanks again![/color]
        >
        > You don't. The form is submitted, so the whole page is 'deleted' as the
        > server responds with a brand new page. Note that the example code provided
        > does not test for features before using them. Include
        > if(document.cre ateElement) {...} and stuff like that before using it in the
        > real world. Also, try to avoid relying on javascript. If you can do it with
        > an ordinary form, and it sounds like you can, then do.[/color]

        If document.create Element() is not supported, what else should we test
        for? Or appendChild? I assume this is GECKO DOM? The alternative would
        be IE's DOM? Or vice versa? Are there mostly 2 DOM's out there to test
        for, or more?

        Is it possible to submit the forms without submitting the page? If
        possible that might be a nice way to do an interface for a chat
        software running PHP and MySql in the background.

        Comment

        • Michael Winter

          #19
          Re: question about post/get

          On 18 Nov 2004 12:56:22 -0800, lawrence <lkrubner@geoci ties.com> wrote:

          Just briefly...

          [snip]
          [color=blue]
          > If document.create Element() is not supported, what else should we test
          > for? Or appendChild? I assume this is GECKO DOM?[/color]

          No, it's the W3C - the standardised - DOM. Microsoft just doesn't support
          it too well.
          [color=blue]
          > The alternative would be IE's DOM?[/color]

          Pretty much. However, IE does support those methods you mentioned. There
          aren't any alternatives as far as I know.

          [snip]

          Mike

          --
          Michael Winter
          Replace ".invalid" with ".uk" to reply by e-mail.

          Comment

          Working...