adsense


Saturday, 28 November 2015

C++ LANGUAGE PASSING DROPDOWN BOX DATA TO CGI PROGRAM

COMPUTER LANGUAGES HTML,C,C++.JAVA,.NET AND MULTIMEDIA basics and programs click home button



C++ LANGUAGE PASSING DROPDOWN BOX DATA TO CGI PROGRAM






Passing Dropdown Box Data to CGI Program 


Dropdown Box is used when we have many options available but 
only one or two will be selected. 

Here is example HTML code for a form with one dropdown box: 
<form action="/cgi-bin/cpp_dropdown.cgi"  
                       method="post" target="_blank"> 
<select name="dropdown"> 
<option value="Maths" selected>Maths</option> 
<option value="Physics">Physics</option> 
</select> 
<input type="submit" value="Submit"/> 
</form> 
The result of this code is the following form: 
  MathsSubmit
Below is C++ program, which will generate cpp_dropdown.cgi script 
to handle input given by web browser through drop down box. 

#include <iostream> 
#include <vector>   
#include <string>   
#include <stdio.h>   
#include <stdlib.h>  
 
#include <cgicc/CgiDefs.h>  
#include <cgicc/Cgicc.h>  
#include <cgicc/HTTPHTMLHeader.h>  
#include <cgicc/HTMLClasses.h>  
 
using namespace std; 
using namespace cgicc; 
 
int main () 
{ 
   Cgicc formData; 
   
   cout << "Content-type:text/html\r\n\r\n"; 
   cout << "<html>\n"; 
   cout << "<head>\n"; 
   cout << "<title>Drop Down Box Data to CGI</title>\n"; 
   cout << "</head>\n"; 
   cout << "<body>\n"; 
 
   form_iterator fi = formData.getElement("dropdown");   
   if( !fi->isEmpty() && fi != (*formData).end()) {   
      cout << "Value Selected: " << **fi << endl;   
   } 
   
   cout << "<br/>\n"; 
   cout << "</body>\n"; 
   cout << "</html>\n"; 
    
   return 0; 
} 


No comments: