How to get value of an input box into php? is it possible? syntax?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Brown - identify

    #1

    How to get value of an input box into php? is it possible? syntax?

    Hello,


    My goal is to make an input check box that saves an input text to a
    cookie when checked and destroys the cookie when unchecked.
    I figured i could use the onclick method of the input box to execute
    the PHP function setcookie, but how do I get the value from the input
    text? Testing with the window.alert function, inputtextName.v alue
    doesn't work in the PHP:

    <html>
    Your name:
    <input class="selectst yle" type="checkbox" name="savename"
    onclick='window .alert("savenam e.value")'><br>

    <input class="inputsty le2" type="text" name="name" value="<?php echo
    $_COOKIE["name"]; ?>">

    literally "savename.value " is alerted.

    I need the cookie value to echo.


    Help is appreciated,

    Matt

  • Jerry Stuckle

    #2
    Re: How to get value of an input box into php? is it possible? syntax?

    Matt Brown - identify wrote:
    Hello,
    >
    >
    My goal is to make an input check box that saves an input text to a
    cookie when checked and destroys the cookie when unchecked.
    I figured i could use the onclick method of the input box to execute
    the PHP function setcookie, but how do I get the value from the input
    text? Testing with the window.alert function, inputtextName.v alue
    doesn't work in the PHP:
    >
    <html>
    Your name:
    <input class="selectst yle" type="checkbox" name="savename"
    onclick='window .alert("savenam e.value")'><br>
    >
    <input class="inputsty le2" type="text" name="name" value="<?php echo
    $_COOKIE["name"]; ?>">
    >
    literally "savename.value " is alerted.
    >
    I need the cookie value to echo.
    >
    >
    Help is appreciated,
    >
    Matt
    >
    Matt,

    I don't understand quite what you're trying to do - but you can't call a
    PHP function from an onclick() message. The PHP code is executed on the
    server before the page ever gets sent to the client.

    You could use AJAX to call back to the server - but it seems like an
    awful lot of trouble. Whatever you're trying to accomplish, there must
    be better ways of doing it.


    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    Working...