Set a variable when button is clicked
Can anyone help me to write the code in java script. I am new to it.
I have the save button. When Save button is clicked which I presently configured like "<INPUT TYPE=button VALUE="Save" ONCLICK="savemethod()">
I need to write the code so that when the save button is clicked, I need to set the form variable in savemethod() so that I can use that variable later in the code. After it sets the variable to something(either integer or true), I will write something like this:
If saveformvariable = true/1
then write to database (i mean upadte to database)
else Don't update.
How can I set the Form variable when the button is clicked. Can soemone help me out plzzzzzzzzz.....It is a bit urgent.....Thanks a lot in advance.
Do you have any back-end (server-side) language, or is this just pure HTML ?
It has server side code. It is classic asp page. I had to implement the save button in it. Before it was a form data entry and submit button. Now I have to implement the save button. I have written the update statement in the code.
Now when clicked on saev button, it saves the data to database. But once you logged out and log back in, the data in the database is getting refreshed and saved as null. I am trying to implement like this:
Similarly, when the page is redirect from previous page,if it can set a value for another variable here then I can use that condition as well.
Hope I explained it correctly.
Thanks for Replying me and helping me out.
<INPUT TYPE=button Name="savebutton" VALUE="Save" ONCLICK="savemethod()">
savevar = evalform.savebutton.value;
var variable = 1
document.evalform.method = "post";
IN THE CODE:
If variable = 1 then
first_Name = request.form("First_Name")
Update statement - updates the database row.
Maybe I am mis-understanding, but would it not make more sense to ensure that the data in the page gets updated FROM the database every time the page is refreshed?
I am not an expert on ASP, but it rather sounds like you have that side of things a little bit wrong.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)