SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help - Converting values

    Need help converting the code where it will accept and process
    inputs from checkbox to text

    This is the html code:
    Code:
    <form action="process.php" method="post">
    <p>What is your name?</p>
    <p><input type="text" name="customer_name"></p>
    
    <p>What orders do you want?</p>
    <p>
    <input type="checkbox" name="hworder[]" value="order01"> Order01
    <br />
    <input type="checkbox" name="hworder[]" value="order02"> Order02
    <br />
    <input type="checkbox" name="hworder[]" value="order03"> Order03
    <br />
    <input type="checkbox" name="hworder[]" value="order04"> Order04</p>
    <input type="submit">
    </form>
    This is the process.php code:
    PHP Code:
    <?php

    $hworder 
    $_POST["hworder"];
    $customer_name strval($_POST["customer_name"]);

    if (
    is_array($hworder)) {
    foreach (
    $hworder as $key => $value) {
    print 
    "$customer_name ordered $value .<br>";
    }
    }

    ?>
    It processes the checkboxes with no problem when I convert to text and try to get only values that I've submitted. Instead of receiving all.

    Ok thats where I'm at.
    Help please.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm just now learning how to get information from one page to another. So I'm using a script that I found and modifying it to where instead of using checkboxes I can receive info from text input and receive only that which was entered and submitted

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2009
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure if i understand, if you are using checkboxes then only those that are checked will be sent by POST not all of them, so it works fine?

  4. #4
    SitePoint Enthusiast
    Join Date
    Jan 2009
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm trying to convert the check boxes to text input.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •