Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,343 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,749 people online right now. Registration is fast and FREE... Join Now!




C++ CGI Program drop down box

 
Reply to this topicStart new topic

C++ CGI Program drop down box, C++ CGI Program drop down box, Having trouble getting a drop down box

raiderspader
post 12 Mar, 2008 - 04:27 PM
Post #1


New D.I.C Head

*
Joined: 22 Oct, 2007
Posts: 4


My Contributions


Hello, I am trying to use code that will multiply a quantity from 1 through 5 by a price (that is currently set to one to test) to give me a total so the way it is now it should just give me the quantity I selected from the drop down box. I tried using else if statements and if statements. If I use the else if statement it will always give me a one and if I use if statements it will always give me a five. I think it's something simple but can't figure out how to make it work. I did a similar program in perl and had no problem but with this one in C++ I just can't get it to work. If anyone can help me it would be greatly appreciated because this is really driving me crazy at this point.

The site this is on is:

http://157.62.23.204/~smithc0/New%20folder/newcpp.cgi

And the Code is:

CODE

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
    float Total =0.00;
    float Price =1.00;
    char Flower;
    int Quanity =0;
    
    if ("quanity = 1")
        Quanity = 1;
    else if ("quanity = 2")
        Quanity = 2;
    else if ("quanity = 3")
        Quanity = 3;
    else if ("quanity = 4")
        Quanity = 4;
    else if ("quanity = 5")
        Quanity = 5;

    Total = Quanity * Price;
    cout << "Content-type: text/html\n\n";
    cout << "<html>"
    << "<head>"
    << "<title>Total</title>"
    << "<body>"
    << "<br /><table cols=5 border=1>"
    << "<tr>"
    << "<th>Delete</th>"
    << "<th>Flower</th>"
    << "<th>Price</th>"
    << "<th>Quanity</th>"
    << "<th>Total</th>"
    << "</tr>"

    << "<tr>"
    << "<td><div align=center><input type=checkbox></td>"
    << "<td><div align=left>"

    << "</td>"
    << "<td><div align=center>"
    << Price
    << "<td><div align=center>"
    << "<select name=quanity>"
    << "<option value=1>1"
    << "<option value=2>2"
    << "<option value=3>3"
    << "<option value=4>4"
    << "<option value=5>5"
    << "</select></td>"
    << "</div>"
    << "<td><div align=center>"
    << Total
    << "</td>"
    << "</tr>"
    << "</body>"
    << "</html>";
}

User is offlineProfile CardPM

Go to the top of the page


NickDMax
post 12 Mar, 2008 - 04:45 PM
Post #2


2B||!2B

Group Icon
Joined: 18 Feb, 2007
Posts: 2,856



Thanked 46 times

Dream Kudos: 550
My Contributions


...well you have the first half... next half is to submit the change in amount and send that input back to your program. You will need to change your HTML so that it will submit the result back to the CGI program... you also need to change your CGI program to deal with input.

The input comes in the standard way, just as if a user had typed it, except that users don't usually type in url encoded value pairs.

I would begin with a simple submit button in the HTML, and another simple CGI page that showed me what in input was when the user submitted that page -- then I would add the input routines to break up the value pairs and do the multiplication.
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/19/08 03:54PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month