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!

Can I see server variables from my client code 1

Status
Not open for further replies.

wf

Programmer
Feb 1, 2001
32
US
I am looking a value from a table in a server code. Then I want to assign this value to a html textbox but I can't.

How can I do that?

This is more or less my code:


<SCRIPT LANGUAGE=vbscript RUNAT=Server>
x = rstrecordset.Fields(&quot;fecha_nac&quot;)
y = rstrecordset.Fields(&quot;seg_soc&quot;)
</SCRIPT>


<BODY>


<IMG SRC=&quot;../images/AnimatedImages/aniearth.gif&quot;>
<INPUT type=&quot;text&quot; id=text3 name=text3 value=&quot;<%=y%>&quot;>
<P>&nbsp;</P>


</BODY>
 
Mmmm, did you write all code here? Your page should contain
a sql instruction and database connections.

So something like this:


sql = &quot;Select top 1 fecha_nac,seg_soc FROM MyDbf&quot;
Set Conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
Conn.Open &quot;(connection string)&quot;
Set rs = Server.CreateObject(&quot;ADODB.Recordset&quot;)
rs.Open sql, Conn

response.write &quot;<input type=text name=text3 value='&quot; &_
server.HTMLEncode(rs(1)) & &quot;'>&quot;

br
Gerard
 
Yes I have that code and I can assign the value to the variable x. That's ok. The problem is that I don't know how to assign the value to my html textbox, if it is possible.
 
Hello,
<SCRIPT LANGUAGE=vbscript RUNAT=Server>
x = rstrecordset.Fields(&quot;fecha_nac&quot;)
y = rstrecordset.Fields(&quot;seg_soc&quot;)
</SCRIPT>
is a different space than ASP directive <% %>
Although both ar erun at server side you do not have access in ASP part to what you have defined in VBScript part.
Try
<%
x = rstrecordset.Fields(&quot;fecha_nac&quot;)
y = rstrecordset.Fields(&quot;seg_soc&quot;)
%>

and you should be able to see the value of y in ASP directive <%=y%>

Hope this helps.
D.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top