[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Need help with form input

Posted on 2009-02-11
11
Medium Priority
?
173 Views
Last Modified: 2012-05-06
Hi,

On this web page:

http://test dot magickitchen dot com slash menu slash MKMeals slash MKMP14 dot html

I have a form. I'm trying to adapt it from the code I've pasted here that usually adds an item to the cart. But I want the checkboxes to allow me to add more than one item to the cart. No more than two, though. Is that possible? I can't access the back end, that's written by our developer, I'm trying to get around that.
<tr class="Body"> 
              <form method="post"  action="/cgi/cart.cgi">
                <input type="hidden" name="cmd" value="add" />
                <input type="hidden" name="sku" value="17113" />
                  <td width="94" class="ItemTitle">7 Servings </td>
                  <td width="62" align="right" class="ItemTitle">$65.00</td>
                  <td width="62" align="right"><input name="qty" size="2" maxlength="6" value="1" type="text"></td>
                  <td width="108" align="center"><input type='image'  name="submit" border="0" src="/img/mkitchen/add_cart-2.gif"></td>
              </form>  
                </tr>

Open in new window

0
Comment
Question by:mel200
  • 6
  • 5
11 Comments
 
LVL 16

Expert Comment

by:sunithnair
ID: 23615333
What is the ned to check box? You have a textbox to specify the number of items to add right (Line 7). We can restrict that to have a value of max 2. Is thsi what you want?
0
 

Author Comment

by:mel200
ID: 23615428
I want the customer to be able to select meal pack one and meal pack three, OR Meal pack four and Meal Pack five, etc. I want them to be able to select any two they would like, and have those two meal packs go to the cart.
0
 
LVL 16

Expert Comment

by:sunithnair
ID: 23615475
But then again it depends on how your cart.cgi has been coded. We can change the html but it might not work properly because cart.cgi had not been coded to take care of this situation
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:mel200
ID: 23615623
I understand- this is a test site, so let's try it and see if it works, ok?
0
 
LVL 16

Expert Comment

by:sunithnair
ID: 23615686
How many meal packs do you have on the site?
0
 
LVL 16

Expert Comment

by:sunithnair
ID: 23615715
Do you have any idea why the following hidden fields are used for?

<input type="hidden" name="cmd" value="add" />
<input type="hidden" name="sku" value="17113" />
0
 

Author Comment

by:mel200
ID: 23615728
I have sic meal packs, and the hidden fields are to add an item to the cart and the SKU of the pack.
0
 
LVL 16

Expert Comment

by:sunithnair
ID: 23615751
What is sku and what does the id represent? I will in the meantime so the html page
0
 

Author Comment

by:mel200
ID: 23615890
A SKU is a retailers code for an item they are selling. In this case, 17113 is the SKU for Meal Plan one, 27113 is the SKU for Meal Plan two, etc.
0
 
LVL 16

Accepted Solution

by:
sunithnair earned 2000 total points
ID: 23617108
This is how the HTML will be but I am 100% certain that it will not work as you will need to change the cart.cgi file
<html>
<head>
    <script language="javascript">
        function Validate() {
            var checkBoxes = document.getElementsByTagName("input");
            var countSelected = 0;
            for (var i = 0; i < checkBoxes.length; i++) {
                if (checkBoxes[i].type == "checkbox" && checkBoxes[i].selected) {
                    countSelected++;
                    if (countSelected > 2)
                        break;
                }
            }
            if (countSelected > 2) {
                alert("Please select only two items to add");
                return false;
            }
            else
                document.forms[0].submit();
        }
    </script>
</head>
<body>
<form method="post"  action="/cgi/cart.cgi">
    <input type="hidden" name="cmd" value="add" />
<table cellpadding="0" cellspacing="0">
<tr class="Body"> 
    <td width="94" class="ItemTitle">7 Servings </td>
    <td width="62" align="right" class="ItemTitle">$65.00</td>
    <td width="62" align="right"><input type="hidden" name="sku1" value="17113" /><input name="qty1" size="2" maxlength="6" value="1" type="text"></td>
    <td width="108" align="center"><input type="checkbox" name="item1"></td>
</tr>
<tr class="Body"> 
    <td width="94" class="ItemTitle">7 Servings </td>
    <td width="62" align="right" class="ItemTitle">$65.00</td>
    <td width="62" align="right"><input type="hidden" name="sku2" value="17113" /><input name="qty2" size="2" maxlength="6" value="1" type="text"></td>
    <td width="108" align="center"><input type="checkbox" name="item2"></td>
</tr>
<tr class="Body"> 
    <td width="94" class="ItemTitle">7 Servings </td>
    <td width="62" align="right" class="ItemTitle">$65.00</td>
    <td width="62" align="right"><input type="hidden" name="sku3" value="17113" /><input name="qty3" size="2" maxlength="6" value="1" type="text"></td>
    <td width="108" align="center"><input type="checkbox" name="item3"></td>
</tr>
<tr class="Body"> 
    <td width="94" class="ItemTitle">7 Servings </td>
    <td width="62" align="right" class="ItemTitle">$65.00</td>
    <td width="62" align="right"><input type="hidden" name="sku4" value="17113" /><input name="qty4" size="2" maxlength="6" value="1" type="text"></td>
    <td width="108" align="center"><input type="checkbox" name="item4"></td>
</tr>
<tr class="Body"> 
    <td width="94" class="ItemTitle">7 Servings </td>
    <td width="62" align="right" class="ItemTitle">$65.00</td>
    <td width="62" align="right"><input type="hidden" name="sku5" value="17113" /><input name="qty5" size="2" maxlength="6" value="1" type="text"></td>
    <td width="108" align="center"><input type="checkbox" name="item5"></td>
</tr>
<tr class="Body"> 
    <td width="94" class="ItemTitle">7 Servings </td>
    <td width="62" align="right" class="ItemTitle">$65.00</td>
    <td width="62" align="right"><input type="hidden" name="sku6" value="17113" /><input name="qty6" size="2" maxlength="6" value="1" type="text"></td>
    <td width="108" align="center"><input type="checkbox" name="item6"></td>
</tr>
<tr>
    <td colspan="4"><input type='image'  name="submit" border="0" src="/img/mkitchen/add_cart-2.gif" onclick="return Validate();"></td>
</tr>
</table>
</form>  
</body>
</html>

Open in new window

0
 

Author Closing Comment

by:mel200
ID: 31545729
Thanks- you're right, it doesn't work because of cart.cgi, but you did give me the right answer. Thanks for your help!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

865 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question