adsense


Saturday, 28 November 2015

C++ LANGUAGE PASWSING RADIO BUTTON DATA TO CGI PROGRAM

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



C++ LANGUAGE PASWSING RADIO BUTTON DATA TO CGI PROGRAM




Passing Radio Button Data to CGI Program 


Radio Buttons are used when only one option is required to be selected. 
Here is example HTML code for a form with two radio button: 
<form action="/cgi-bin/cpp_radiobutton.cgi"  
         method="post"  
         target="_blank"> 
<input type="radio" name="subject" value="maths"  
                                    checked="checked"/> Maths  
<input type="radio" name="subject" value="physics" /> Physics 
<input type="submit" value="Select Subject" /> 
</form> 
The result of this code is the following form: 
 Maths  Physics  Select Subject

Below is C++ program, which will generate cpp_radiobutton.cgi script 
to handle input given by web browser through radio buttons. 

#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>Radio Button Data to CGI</title>\n"; 
   cout << "</head>\n"; 
   cout << "<body>\n"; 
 
   form_iterator fi = formData.getElement("subject");   
   if( !fi->isEmpty() && fi != (*formData).end()) {   
      cout << "Radio box selected: " << **fi << endl;   
   } 
   
   cout << "<br/>\n"; 
   cout << "</body>\n"; 
   cout << "</html>\n"; 
    
   return 0; 
} 


No comments: