Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Oct 2006
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Passing variables to form- adding multiple items automaticly

    I'm creating a type of shopping cart/order form for a client, a very simple one.

    So far I've been able to pass variables into a form on a different page using a getData function. Basically this lets me assign variables in a link that the customer clicks. When they click the link they're brought to the orderform page and see that the data from the item they picked is already filled into the form (the item type and design are specified via a drop-down list and a textfield).

    Now I'd like to expand this little project so that when a customer clicks the item and their order is filled out, they can have the option of continuing to shop. (the orderform would need to be saved. via cookie?)

    In order for this to work I'm also going to have to somehow make the script work so that if an item is already specified and the customer clicks another link, a new item will be added.

    I know what i want to do... I just have no idea how to get there. I don't know much about PHP, but would like to attempt this anyhow.

    Here is my code so far:

    PHP Code:
    <script type="text/javascript">
    <!--
    var 
    dataPassed ''

    function getData(){
    if (
    location.search.length 0){
    dataPassed unescape(location.search.substring(1))

    tempArray=dataPassed.split("="// create the array tempArray
    document.form.item.value=tempArray[0]
    document.form.design.value=tempArray[1]
    }
    }

    //-->
    </script> 


    <h2>Items</h2>
    <form method="post" name="form" action="order_process.php">
    <label>Item 1</label>
        <select name="item" value=""><option>Please Select</option><option value="Flowerpot" name="Flowerpot">Flowerpot</option><option value="Birdhouse" 

    name="Birdhouse">Birdhouse</option></select>
    <label>Design:</label>
        <input type="text" name="design" value="" style="width:350px;"/>
    </form> 
    Last edited by KELS!; 07-15-2007 at 11:59 PM. Reason: More Info

  • #2
    Master Coder mlseim's Avatar
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,373
    Thanks
    8
    Thanked 1,075 Times in 1,066 Posts
    I think it's noble of you to attempt this yourself, probably a good learning
    experience with PHP, but if your final goal is an actual working shopping cart
    that you will be using, I really do suggest customizing an existing PHP/MySQL
    script (like CubeCart) .... something that's free, and you can mess around with.

    But, I found this using Google:
    http://www.google.com/search?hl=en&s...rt&btnG=Search

    I don't know which example is the best because I've never taken the time
    to code my own cart ... it's just not worth the effort (my personal opinion).

  • #3
    New Coder
    Join Date
    Oct 2006
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I'm actually looking for more of an orderform- it's just going to 'appear' to be a shopping cart....

    Right now I think I'm going to scale back to only having an "add more items" option which populates more fields.

    Anyone know of a good tutorial to allow me to do that?


  •  

    Posting Permissions

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