vendredi 20 février 2015

Read data from the HTML form, in C++ (fcgi application)


I am working on fcgi application. Wherein we have a c/C++ code base that has html code embedded in it.


I am trying to access the data filled in the form by the user. The user hasn't submitted the form yet.


I am trying to access this filled up form from the c++ code before it gets submitted.


Can anyone please either help me with how to pass the data from the JavaScript to the C++ code, or how to directly access it from the c++ code.


Following is the sample code:



void web_crete_form(ostringstream os)
{
os << "<html>";
os << "<head>";

os << "<script type='text/javascript'>";
/* I want to use the following value (Last Name) in this same c++ code, to evaluate other things, send back an evaluated value to this script, and throw an alert accordingly. */
os << "var name_Last=document.getElementById('nameLast').value;";
os << "function validateData()";
os << "{";
os << "var name_First=document.getElementById('nameFirst').value;";
os << "if (data==null || data=='')";
os << "{";
os << " alert('Please fill in the Name.');";
os << " return false;";
os << "}";

os << "<title>Data Collection</title>\n";
os << "</head>";
os << "<body>";

os << "<form name='collection' id='collection' method='post' action='' onsubmit='return validateData()'>";
os << "<label>";
os << "<span>Name:</span>";
os << "<input type='text' size='50' id='nameFirst' name='nameGiven' value=''/>";
os << "</label>";
os << "<label>";
os << "<span>Last Name:</span>";
os << "<input type='text' size='50' id='nameLast' name='namelast' value=''/>";
os << "</label>";
os << "</form>";
os << "</body>";
os << "</html>";
}


I am ready to provide with some more info if needed.




Aucun commentaire:

Enregistrer un commentaire