Reputation: 11
<script>
function OnInit(s, e) {
var input = s.GetInputElement();
var MyValue = TextBox.GetValue(); // Question is here
ASPxClientUtils.AttachEventToElement(input, "click", function (event) {
s.SetText("");
});
}
function onLostFocus(s, e) {
if (s.GetText() == '')
s.SetSelectedIndex(0);
}
</script>
I want to use "MyValue " in onLostFocus function.
How can i get "MyValue" in onLostFocus function?
Any help will be appreciated.
Upvotes: 1
Views: 229
Reputation: 28845
You have to change the variable scope so its available for both functions.:
<script>
var MyValue; // define the variable outside the function
function OnInit(s, e) {
var input = s.GetInputElement();
MyValue = TextBox.GetValue();
ASPxClientUtils.AttachEventToElement(input, "click", function (event) {
s.SetText("");
});
}
function onLostFocus(s, e) {
if (s.GetText() == '')
s.SetSelectedIndex(0);
}
</script>
Upvotes: 4