HELP: Reading javascript var from PHP

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

    HELP: Reading javascript var from PHP

    I have a simple screen:
    1 question, 4 answers (A,B,C,D)

    The user clicks on a letter (answer) and it highlights the answer.
    (Javascript)

    When the use clicks NEXT I want PHP code to run and store the users choice
    in a MySql db.

    Any idea how to get the users "answer" from PHP?

    Thanks!


  • Michael Winter

    #2
    Re: HELP: Reading javascript var from PHP

    On Wed, 27 Oct 2004 21:29:41 GMT, Cirene <dont@email.m e> wrote:
    [color=blue]
    > I have a simple screen:
    > 1 question,[/color]

    Some text.
    [color=blue]
    > 4 answers (A,B,C,D)[/color]

    Four radio buttons.
    [color=blue]
    > The user clicks on a letter (answer) and it highlights the answer.
    > (Javascript)[/color]

    Fair enough.
    [color=blue]
    > When the use clicks NEXT[/color]

    A submit button.
    [color=blue]
    > I want PHP code to run and store the users choice in a MySql db.[/color]

    The form is submitted and the server-side code gets the form data.
    [color=blue]
    > Any idea how to get the users "answer" from PHP?[/color]

    Provide a link, or server-side redirect, to a PHP page that reads from the
    database.

    I'm now a little confused. Your subject suggests that you want PHP to get
    the a script value (and I don't see where that fits in so far). The
    question immediately above suggests that you want to read from the
    database. Which is it?

    Mike

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

    Comment

    • Cirene

      #3
      Re: HELP: Reading javascript var from PHP

      Thanks for the response.

      From an interactivity standpoint...
      1. Page loads and reads the question and the 4 corresponding answers from a
      MySql db.
      2. User selects their answer and it's highlighted.
      3. User clicks next and their answer is written to the database.

      Does that help?

      "Michael Winter" <M.Winter@bluey onder.co.invali d> wrote in message
      news:opsgjto1xa x13kvk@atlantis ...[color=blue]
      > On Wed, 27 Oct 2004 21:29:41 GMT, Cirene <dont@email.m e> wrote:
      >[color=green]
      >> I have a simple screen:
      >> 1 question,[/color]
      >
      > Some text.
      >[color=green]
      >> 4 answers (A,B,C,D)[/color]
      >
      > Four radio buttons.
      >[color=green]
      >> The user clicks on a letter (answer) and it highlights the answer.
      >> (Javascript)[/color]
      >
      > Fair enough.
      >[color=green]
      >> When the use clicks NEXT[/color]
      >
      > A submit button.
      >[color=green]
      >> I want PHP code to run and store the users choice in a MySql db.[/color]
      >
      > The form is submitted and the server-side code gets the form data.
      >[color=green]
      >> Any idea how to get the users "answer" from PHP?[/color]
      >
      > Provide a link, or server-side redirect, to a PHP page that reads from the
      > database.
      >
      > I'm now a little confused. Your subject suggests that you want PHP to get
      > the a script value (and I don't see where that fits in so far). The
      > question immediately above suggests that you want to read from the
      > database. Which is it?
      >
      > Mike
      >
      > --
      > Michael Winter
      > Replace ".invalid" with ".uk" to reply by e-mail.[/color]


      Comment

      • Lee

        #4
        Re: HELP: Reading javascript var from PHP

        Cirene said:[color=blue]
        >
        >I have a simple screen:
        >1 question, 4 answers (A,B,C,D)
        >
        >The user clicks on a letter (answer) and it highlights the answer.
        >(Javascript)
        >
        >When the use clicks NEXT I want PHP code to run and store the users choice
        >in a MySql db.
        >
        >Any idea how to get the users "answer" from PHP?[/color]

        Typically, the client's browser submits a form to a PHP server page
        which stores the answer and then presents the next page.

        Comment

        • Michael Winter

          #5
          Re: HELP: Reading javascript var from PHP

          On Wed, 27 Oct 2004 21:52:24 GMT, Cirene <dont@email.m e> wrote:
          [color=blue]
          > From an interactivity standpoint...
          > 1. Page loads and reads the question and the 4 corresponding answers
          > from a MySql db.
          > 2. User selects their answer and it's highlighted.
          > 3. User clicks next and their answer is written to the database.[/color]

          I described how to do that. The answers are written as radio buttons in a
          form, and your "Next" button is that form's submit button. The action of
          the form refers to a PHP which reads the submitted value and adds it to
          the database.

          The specifics are not on-topic in this group. You'd have to ask in either
          alt.php or comp.lang.php.
          [color=blue]
          > Does that help?[/color]

          Sort of. It shows I understand what you're trying to do, but not what
          you're asking.

          I'm sorry, but aside from highlighting the selected answer, this
          "question", as written, has nothing to do with Javascript. It's PHP and
          basic HTML.

          [snip]

          Mike

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

          Comment

          Working...