form problems

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

    form problems

    Hi!

    I have a voting pool and when user hits "vote" I want a pop up to appear
    with results
    So I put in form action (window.open(.. .....)) and the pop up appears but
    the main page changes to blank.
    please help

    another thing:
    I tried to do document.formna me.submit() in a function and it doesn't work!
    but when I put the same code in href I works. I don't get it :-(

    thanks, Gordan


  • kaeli

    #2
    Re: form problems

    In article <botmbk$hr4$1@l s219.htnet.hr>, gordanMENE@tork ulMAKNI.hr
    enlightened us with...[color=blue]
    > Hi!
    >
    > I have a voting pool and when user hits "vote" I want a pop up to appear
    > with results
    > So I put in form action (window.open(.. .....)) and the pop up appears but
    > the main page changes to blank.
    > please help
    >[/color]

    That would be because the form submitted. Instead of putting the popup
    in the action, change the target.
    [color=blue]
    > another thing:
    > I tried to do document.formna me.submit() in a function and it doesn't work!
    > but when I put the same code in href I works. I don't get it :-(
    >[/color]

    I don't either without seeing some code to see if everything is defined
    properly. "doesn't work" isn't very descriptive, either. It's like going
    to a mechanic and telling him your car doesn't work.

    -------------------------------------------------
    ~kaeli~
    Jesus saves, Allah protects, and Cthulhu
    thinks you'd make a nice sandwich.


    -------------------------------------------------

    Comment

    • Michael Winter

      #3
      Re: form problems

      "Gordan" wrote on 12/11/2003:
      [color=blue]
      > Hi!
      >
      > I have a voting pool and when user hits "vote" I want a pop up to[/color]
      appear[color=blue]
      > with results
      > So I put in form action (window.open(.. .....)) and the pop up[/color]
      appears but[color=blue]
      > the main page changes to blank.
      > please help[/color]

      This is part of how forms work: when the form is submitted, the
      current document is changed to that specified by the URL in the
      'action' attribute, and the form data is sent according to the
      'method' specified. You can't change this behaviour.

      I would solve this by sending the data to a processing page, and have
      that launch your pop-up. If you're using a server-side scripting
      language, like PHP, in addition to JavaScript, you could use the POST
      method. If not - just HTML and JavaScript - then you'll have to use
      GET. However, if the data you submit is private or sensitive in any
      way, you shouldn't do this: GET form data is sent in the URL, which
      isn't secure.

      When you submit using GET, the name/value pairs of all the successful
      controls on your form are appended to the URL, like so:

      http://www.somesite.com/apage.html?c...ontrol2=value2 ...
      etc.

      You can retreive this information from the 'search' property of the
      window's Location object (window.locatio n). The 'search' property
      returns everything from the ? onwards. In this case:
      ?control1=value 1&control2=valu e2 Note that spaces are replaced with
      plus (+) symbols**, and some characters are escaped (like escape() was
      used on them), so you'll want to use unescape() on any values that
      might have escaped characters in them.
      [color=blue]
      > another thing:
      > I tried to do document.formna me.submit() in a function and it[/color]
      doesn't work![color=blue]
      > but when I put the same code in href I works. I don't get it :-([/color]

      How have you been trying to submit the form? From an event handler on
      a link or similar object? This works in IE 6, but we know that's no
      guarantee:

      <A href="#" onclick="docume nt.myForm.submi t(); return
      false">Submit</A>


      ** If a string contains spaces, they are replaced by plus (+) symbols.
      Any original plus symbols (those not converted from spaces) are
      escaped, so there will be no confusion. This means that you can first
      convert any plus symbols to spaces, then use unescape() on the string.

      Mike

      --
      Michael Winter
      M.Winter@[no-spam]blueyonder.co.u k (remove [no-spam] to reply)


      Comment

      Working...