I am using nodejs ,html,express , node-nosql and JavaScript. I have a problem wherin the html page is given below :
<body>
<form name="form1" method="post" onSubmit="createTable();return myFunction();">
<input type ="text" name="DomainName" id="Domain_name" required="" />
<input type="submit" value="Submit" />
</form>
<form name="form2" action="http://www.cs.tut.fi/cgi-bin/run/~jkorpela/echo.cgi" method="post">
<div id="table_container"></div>
<input type="submit" value="submit" />
</form>
</body>
The javascriptFunction is as below:
function myFunction() {
var input_domain = document.forms["form1"]["DomainName"].value;
if (input_domain == null || input_domain == "") {
alert("Please enter a valid domain");
return;
}
return false;
}
function createTable() {
document.getElementById("table_container").innerHTML = "";
var input_domain = document.forms["form1"]["DomainName"].value;
if (input_domain == null || input_domain == "") return;
var names = ["website1", "website2"];
var table = document.createElement("table"),
...using javascript dynamically create a table with certain columns for each of the websites listed in the var names list ...
document.getElementById("table_container").appendChild(table);
</script>
The Problem i am facing now is , when i click on submit button of form1 , the
var names = ["website1", "website2"];
has to be retrieved from database . I know i have to use the ajaxrequest with nodejs. But i am at a loss as to how it should be returned and processed ! Please help .