Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textbox DTC and OnBlur

Status
Not open for further replies.

TheDrParker

Programmer
Nov 21, 2001
55
0
0
US
Can I use onblur with a Textbox DTC withouth changing it to a TextArea? Basically I need to keep it a Textbox and find the value it possesses before it loses focus.

Thanx
 
Hi,

Why would you want to change your texbox to a Textarea?
I don't understand the question.

To use onblur event on Textbox DTC's you have to:

<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>

Sub thisPage_onenter()
Textbox1.advise &quot;onblur&quot;, &quot;MyFunc&quot;
End Sub

</SCRIPT>

<script language=javascript>
function thisPage_onbeforeserverevent(obj,evnt){
if (obj==&quot;Textbox1&quot;){
if (evnt==&quot;onblur&quot;){
if (document.thisForm.Textbox1.value != &quot;whatever&quot;){
thisPage.cancelEvent=true;
document.thisForm.Textbox1.focus();
alert(&quot;NOT!&quot;);
else
//do whatever you want here, if you do nothing it will go to the server side function MyFunc, so you'll need to create it, but this is not necessary, if you skip the else part
}
}
}
}
</script>

Hope this helps :) &quot;Defeat is not the worst of failures. Not to have tried is the true failure.&quot;
-George E. Woodberry
 
I changed it to a TextArea because something I read on Microsoft's site listed object you could use onblur with. TextArea was one, but Textbox was not. I'll try out what you suggested.

Thanx
 
I tried what you suggested and I can get it to do the onblur. It will do what I ask in the if and in the else, but after it performs the else it seems to try to execute MyFunc then it runs into an error &quot;This Page Cannot be displayed, with the URL:
I dont' know if it's because my page is VBScript and I'm trying to call a function inside a VBScript block from a Javascript block or what. I tried changing MyFun to a Javascript but this did not help.
 
I got the onblur to work, I didn't include the parenthises for the procedure.
The problem I have now is trying to capture the value in the textbox to update the recordset, or a session variable. I can't use a Session('MyVar') because that's server side, and when I put stuff in the onblur procedure it only takes affect after the page reloads.
Any help greatly appreciated.
 

Hi,

as far as I know storing the value of the textbox in a session variable or updating a recordset allways requires a server round trip, so your page will allways reload.

Why would you want to do this in the onblur event? &quot;Defeat is not the worst of failures. Not to have tried is the true failure.&quot;
-George E. Woodberry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top