Jump to content

How Do You Carry Form Data?


jonmkim

Recommended Posts

I'm trying to create a form that will let users select a list of devices from a dropdown menu and then print the selection back on the page.  After selecting and submitting that one device, the user should then have the option to select another device and add it to their growing list of added devices.

For example, someone should be able to select "Battery," hit "Add device" and then be brought back to the page.  Now, above the dropdown menu it will read, "Battery."  They should be able to continue adding devices which will all be listed above the dropdown menu.

 

Here is my code:

 

            <form name="new_reservation" action="<?=$PHP_SELF?>" method="GET">

            <b>Make a New Reservation</b>

        <li style="list-style-type:none;">

 

    <?php

                    if (isset($_GET)) {

                        // echo "Data has been posted.";

                        $added = $_GET['add_device'];

echo $added;

echo "</li><li style='list-style-type:none;'>";

                    }

                    ?>

                       

                    <select name="add_device">

                    <option value="">Select a device</option>

                    <option value="battery">Battery</option>

                    <option value="card reader">Card Reader</option>

                    <option value="ethernet cable">Ethernet Cable</option>

                    <option value="extension cord">Extension Cord</option>

                    <option value="Firewire cable">Firewire Cable</option>

                    <option value="keyboard">Keyboard</option>

                    <option value="laptop">Laptop</option>

                    <option value="mouse">Mouse</option>

                    <option value="power strip">Power Strip</option>

                    <option value="projector">Projector</option>

                    <option value="speakers">Speakers</option>

                    <option value="USB (mini size)">USB (Mini Size)</option>

                    <option value="USB (standard size)">USB (Standard Size)</option>

                    <option value="VGA Video Cable">Video Cable - VGA</option>

                    <option value="VGA to DVI Video Cable">Video Cable - VGA to DVI</option>

                    <option value="VGA to Mini DVI">Video Cable - VGA to Mini DVI</option>

                    <option value="wacom tablet">Wacom Tablet</option>

                   

                    </select>

                 

                <input name="submit" type="submit" value="+ Add device"></input>

                <input type="hidden" value="<?=$added?>">

                </li>

 

Link to comment
Share on other sites

Wouldn't it be much simpler (for both you and for the user) to add a multiple parameter?

 

http://www.w3schools.com/TAGS/tag_select.asp

 

I would prefer to not do it that way because it would clutter the page.  In addition, we're doing this for people who still call in to make reservations because they can hardly understand their computer.  Ctrl + click probably won't sit well with them.

 

I'm speculating whether I should just create a temp table in the database to store the devices that the user adds, but I think that'd be even more complicated.  No?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.