hi all,
i've 2 text boxes and save button and i wanna when i click save button take the values of 2 textboxes then insert in db,
i know that js is client side and i cannot connect to db with ,so i try to make a hidden field with 2 textboxes and try when i click submit button i'll reload to the same page and check for the value of this hidden field if it is "insert", then go and insert into db....but i canot implement that.
this is what i reload to the same page but how to check for the value of hidden field...?
this is all what i get:
<script language="javascript">
var count = "1";
function add(t)
{
var tbody = document.getElementById("t").getElementsByTagName("TBODY")[0];
// create row
var row = document.createElement("TR");
// create table cell 1 ----- title
var td1= document.createElement("TD")
var strHtml1= "<INPUT TYPE=\"text\" NAME=\"ti\">";
td1.innerHTML = strHtml1.replace(/!count!/g,count);
// create table cell 2 ----- url
var td2 = document.createElement("TD")
var strHtml2 = "<INPUT TYPE=\"text\" NAME=\"ur\">";
td2.innerHTML = strHtml2.replace(/!count!/g,count);
var td3 = document.createElement("TD")
var strHtml3 = "<INPUT TYPE=\"submit\" onClick=\"save()\" VALUE=\"Save\">";
td3.innerHTML = strHtml3.replace(/!count!/g,count);
var td4 = document.createElement("TD")
var strHtml4 = "<INPUT TYPE=\"hidden\" name=\"old\" VALUE=\"Save\">";
td4.innerHTML = strHtml4.replace(/!count!/g,count);
// append data to row
row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
// add to count variable
count = parseInt(count) + 1;
// append row to table
tbody.appendChild(row);
}
function save()
{
document.location.reload();
}
i've 2 text boxes and save button and i wanna when i click save button take the values of 2 textboxes then insert in db,
i know that js is client side and i cannot connect to db with ,so i try to make a hidden field with 2 textboxes and try when i click submit button i'll reload to the same page and check for the value of this hidden field if it is "insert", then go and insert into db....but i canot implement that.
this is what i reload to the same page but how to check for the value of hidden field...?
this is all what i get:
<script language="javascript">
var count = "1";
function add(t)
{
var tbody = document.getElementById("t").getElementsByTagName("TBODY")[0];
// create row
var row = document.createElement("TR");
// create table cell 1 ----- title
var td1= document.createElement("TD")
var strHtml1= "<INPUT TYPE=\"text\" NAME=\"ti\">";
td1.innerHTML = strHtml1.replace(/!count!/g,count);
// create table cell 2 ----- url
var td2 = document.createElement("TD")
var strHtml2 = "<INPUT TYPE=\"text\" NAME=\"ur\">";
td2.innerHTML = strHtml2.replace(/!count!/g,count);
var td3 = document.createElement("TD")
var strHtml3 = "<INPUT TYPE=\"submit\" onClick=\"save()\" VALUE=\"Save\">";
td3.innerHTML = strHtml3.replace(/!count!/g,count);
var td4 = document.createElement("TD")
var strHtml4 = "<INPUT TYPE=\"hidden\" name=\"old\" VALUE=\"Save\">";
td4.innerHTML = strHtml4.replace(/!count!/g,count);
// append data to row
row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
// add to count variable
count = parseInt(count) + 1;
// append row to table
tbody.appendChild(row);
}
function save()
{
document.location.reload();
}