Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to set a variable
Message
From
22/05/2001 23:51:43
 
 
To
22/05/2001 22:18:49
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00510175
Message ID:
00510193
Views:
20
You need to set "OPTMODE" as a variable with page scope by declaring it at the top of the page (or outside of any functions), and then use the onClick event of the buttons to change its value as needed.

You could add code like this inside the 'script' tag:
...
var OPTMODE //declare variable
OPTMODE = "UPDATE" //set a default value

function setVal(who) {
 var val = who.value //capture value
 if (val == "Add") {OPTMODE = "INSERT"}
 //you could implement "else" statements here if you needed to
}
...
The Add button would need to have its value attribute set to 'Add', and the Save button to 'Save'. You need to add the following onClick event at least to the Add button; you could add it to the Save button as well, if you wanted to react to it being pressed, too.
<...onClick="setVal(this)">
Hope this helps!
A. Chiriboga, MCSE, MCP+I


ORIGINAL MESSAGE:
Hi All,
I have one ASP page in which I have two buttons “Add” and “Save”

What I want to do:-
If I click on “Add” button and then Click on “Save” it will insert a record. Or if I click on “Save” button then it will update that record.

For this I want to set a variable “OPTMODE” if I click on “Add” then “OPTMODE” value = “INSERT” otherwise “OPTMODE” = “UPDATE”. How to do that.

In VB its very easy.
Am new in ASP.

Thanks for ur help,
…ashish
Andres M. Chiriboga, MCSE, MCP+I
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform