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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get textbox input

Status
Not open for further replies.

TheDrParker

Programmer
Nov 21, 2001
55
US
I have a textbox DTC connected to a recordset that I want to make updateable. I want to be able to capture the change to use to update the recordset later.

I have tried:
<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
Sub thisPage_onenter()
DataTxtBox1.advise &quot;onblur&quot;, &quot;UpdateRec()&quot;
End Sub
</SCRIPT>

<SCRIPT LANGUAGE=vbscript RUNAT=server>
Sub UpdateRec()
thispage.setTextVal(DataTxtBox1.value)
Response.Write(&quot;Updating Rec:&quot;)
Response.Write(thispage.getTextVal())
Response.Write(&quot;<BR>&quot;)
End Sub
</SCRIPT>

<script language=javascript>
function thisPage_onbeforeserverevent(obj,evnt)
{
if (obj==&quot;DataTxtBox1&quot;)
{
if (evnt==&quot;onblur&quot;)
{
if (DataTxtBox1.value == &quot;&quot;)
{
thisPage.cancelEvent=true;
alert(&quot;No Sir.&quot;);
}
else
{
}
}
}
}
</script>

And I have tried:

<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
Sub DataTxtBox1_onchange()
thisPage.setTextVal(DataTxtBox1.value)
Session(&quot;Test1&quot;) = DataTxtBox1.value
End Sub
</SCRIPT>

In either case after OnChange or OnBlur the page calls itself and the textbox value is reset by recordset. How do I capture the value in the textbox before it is replaced by the value in the recordset when the page is called.

BTW: Session('Test') and thisPage.setTextVal() can't capture it in the onbeforeserverevent because that is client side.

Any help greatly appreciated
 
Hi,

have you tried using Session in Sub UpdateRec(),

<SCRIPT ID=serverEventHandlersVBS LANGUAGE=vbscript RUNAT=Server>
Sub thisPage_onenter()
DataTxtBox1.advise &quot;onblur&quot;, &quot;UpdateRec()&quot;
End Sub
</SCRIPT>

<SCRIPT LANGUAGE=vbscript RUNAT=server>
Sub UpdateRec()
Session(&quot;Test1&quot;) = DataTxtBox1.value
Response.Write(&quot;Updating Rec:&quot;)
There's another Textbox here to check the value of Session(&quot;Test1&quot;)
Textbox2.value = Session(&quot;Test1&quot;)
Response.Write(Session(&quot;Test1&quot;))
Response.Write(&quot;<BR>&quot;)
End Sub
</SCRIPT>

<script language=javascript>
function thisPage_onbeforeserverevent(obj,evnt)
{
if (obj==&quot;DataTxtBox1&quot;)
{
if (evnt==&quot;onblur&quot;)
{
if (document.thisForm.DataTxtBox1.value == &quot;&quot;)
{
thisPage.cancelEvent=true;
alert(&quot;No Sir.&quot;);
}
}
}
}
</script>

This should work. If it doesn't, when do you open your recordset. Maybe there's the problem. &quot;Defeat is not the worst of failures. Not to have tried is the true failure.&quot;
-George E. Woodberry
 
I tried putting the value into the Session variable, but when I print it I get the value that the recordset changed DataTxtBox1 to when the page opened.
I tried capturing the value into the Textbox, but it won't load when I do Textbox2.value = Session(&quot;Test1&quot;). Is Textbox2 even available bofore the Body.
 
Hi,

I made an asp page with one recordset DTC, 2 Textbox DTC's (one is bound to the recordset) and the above code. When the page is loaded it displays the recorset value. When I correct the value and leave the textbox, the corrected value is displayed in Textbox2, so the code works.
The problem probably lies somwhere else. What is the rest of the code on your page and do you use recordset DTC or do you code your own ADO recordset? &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