submit confirmation with radio button selected

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jforena@hotmail.com

    submit confirmation with radio button selected

    Hi,

    I am trying to create a javascript that will display a confirmation
    message when a user submits a form and has specifically selected
    a particular radio button.

    For example:

    <form action="foo.cgi " method="post">
    <input name="question1 " type="radio" value="1">Value 1</input>
    <input name="question1 " type="radio" value="2">Value 2</input>
    <input name="foo" type="submit">
    </form>

    Assuming the user selects the second radio button (Value 2), how would I
    display a message that states "Are you sure you want to do value 2?" and
    then also includes a "Submit" and "Cancel" button?

    Any help would be much appreciated. Thx!

    - JF
  • Paul R

    #2
    Re: submit confirmation with radio button selected

    <form action="foo.cgi " method="post"
    onsubmit="retur n(!this.questio n1[1].checked || confirm('Are you sure you
    want to do value 2?'))">

    .... which says that if the second 'question1' radio button ISN'T checked
    or the user HAS assented to the confirmation message, proceed.

    Comment

    • RobB

      #3
      Re: submit confirmation with radio button selected

      jforena@hotmail .com wrote:[color=blue]
      > Hi,
      >
      > I am trying to create a javascript that will display a confirmation
      > message when a user submits a form and has specifically selected
      > a particular radio button.
      >
      > For example:
      >
      > <form action="foo.cgi " method="post">
      > <input name="question1 " type="radio" value="1">Value 1</input>
      > <input name="question1 " type="radio" value="2">Value 2</input>
      > <input name="foo" type="submit">
      > </form>
      >
      > Assuming the user selects the second radio button (Value 2), how[/color]
      would I[color=blue]
      > display a message that states "Are you sure you want to do value 2?"[/color]
      and[color=blue]
      > then also includes a "Submit" and "Cancel" button?
      >
      > Any help would be much appreciated. Thx!
      >
      > - JF[/color]

      Or...

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
      "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
      <title>untitled </title>
      <script type="text/javascript">

      function chk()
      {
      return confirm('Are you sure you want to do value 2?');
      }

      </script>
      </head>
      <body>
      <form action="foo.cgi " method="post">
      <input name="question1 " type="radio" value="1"
      onclick="this.f orm.onsubmit=nu ll" />Value 1
      <br />
      <input name="question1 " type="radio" value="2"
      onclick="this.f orm.onsubmit=ch k" />Value 2
      <br />
      <br />
      <input name="foo" type="submit">
      </form>
      </body>
      </html>

      <input> tags are singlets (no closing tag).

      Comment

      • jforena@hotmail.com

        #4
        Re: submit confirmation with radio button selected

        Way cool. Thank you both (Paul R & RobB) for the feedback.

        - JF

        Comment

        Working...