PDA

View Full Version : Populating a Text Area


Abd
03-19-2003, 08:30 AM
Hi All,

need help on the below, I want to populate a text area and a radio button with some data from the database but, both
controls return no data when I used the below code;

<%
category = TRIM( Request.Form( "cat" ) )
username = TRIM( Request.Form( "username" ) )



IF username <> "" THEN
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=ARahim4-OFS;UID=sa;PWD=;DATABASE=abdul"
Set RS= Server.CreateObject( "ADODB.Recordset" )

If category = "Branch" then
RS.Open "select * from history where FirstName = '" &username& "'", Con

CandidateCode = RS.Fields("CandidateCode")
FirstName = RS.Fields("FirstName")
Address = RS.Fields("Address")
PositionCode = RS.Fields("PositionCode")
Gender = RS.Fields("Gender")
Comment = RS.Fields("Comment")



End if
Con.Close
Set RS = Nothing
Set Con = Nothing
END IF
%>


<Html>
<head><title>Return Data</title>
<body>
<form name="form1" method="post" action="return1.asp?category=<%=category%>">
<h1 align="center"><font color="blue" size=+2><em>Update Data</em></font></h1>
<b>First Name:</b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="FirstName" type="text" value="<%=Server.HTMLEncode(FirstName)%>" readonly>
<p>
<b>Candidate Code:</b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="CandidateCode" type="text"value="<%=Server.HTMLEncode(CandidateCode)%>" readonly>
<p>
<b>Address:</b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="Address" type="text" value="<%=Server.HTMLEncode(Address)%>" readonly>
<p>
<b>Position Code:</b>
&nbsp;&nbsp;<input name="PositionCode" type="text"value="<%=Server.HTMLEncode(PositionCode)%>" readonly>
<p>
<b>Gender:</b>
<input type="radio" name="gender" value="<%=Server.HTMLEncode(Gender)%>" <%if Gender="female" then response.write "checked" else response.write "disabled"%>>female<br>
<input type="radio" name="gender" value="<%=Server.HTMLEncode(Gender)%>" <%if Gender="male" then response.write "checked" else response.write "disabled"%>>male<br>
<p>
<b>Comment:</b>
<TEXTAREA NAME="Comment" ROWS=5 COL=15 value="<%=Server.HTMLEncode(Comment)%>"></TEXTAREA>
<p>

<p><input type="submit" value="Submit">
</form>

</body>
</html>

__________________
Abd

glenngv
03-19-2003, 08:56 AM
textarea has no value attribute. the content goes in between the textarea tags.

<TEXTAREA NAME="Comment" ROWS=5 COL=15><%=Server.HTMLEncode(Comment)%></TEXTAREA>

Abd
03-19-2003, 01:18 PM
Hi glenngv / All,

thanks the Text Area worked, any help on populating Radio Button, below is my code;

<%
category = TRIM( Request.Form( "cat" ) )
username = TRIM( Request.Form( "username" ) )



IF username <> "" THEN
Set Con = Server.CreateObject( "ADODB.Connection" )
Con.Open "PROVIDER=SQLOLEDB;DATA SOURCE=ARahim4-OFS;UID=sa;PWD=;DATABASE=abdul"
Set RS= Server.CreateObject( "ADODB.Recordset" )

If category = "Branch" then
RS.Open "select * from history where FirstName = '" &username& "'", Con

CandidateCode = RS.Fields("CandidateCode")
FirstName = RS.Fields("FirstName")
Address = RS.Fields("Address")
PositionCode = RS.Fields("PositionCode")
Gender = RS.Fields("Gender")
Comment = RS.Fields("Comment")



End if
Con.Close
Set RS = Nothing
Set Con = Nothing
END IF
%>


<Html>
<head><title>Return Data</title>
<body>
<form name="form1" method="post" action="return1.asp?category=<%=category%>">
<h1 align="center"><font color="blue" size=+2><em>Update Data</em></font></h1>
<b>First Name:</b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="FirstName" type="text" value="<%=Server.HTMLEncode(FirstName)%>" readonly>
<p>
<b>Candidate Code:</b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="CandidateCode" type="text"value="<%=Server.HTMLEncode(CandidateCode)%>" readonly>
<p>
<b>Address:</b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="Address" type="text" value="<%=Server.HTMLEncode(Address)%>" readonly>
<p>
<b>Position Code:</b>
&nbsp;&nbsp;<input name="PositionCode" type="text"value="<%=Server.HTMLEncode(PositionCode)%>" readonly>
<p>
<b>Gender:</b>
<input type="radio" name="gender" value="<%=Server.HTMLEncode(Gender)%>" <%if Gender="female" then response.write "checked" else response.write "disabled"%>>female<br>
<input type="radio" name="gender" value="<%=Server.HTMLEncode(Gender)%>" <%if Gender="male" then response.write "checked" else response.write "disabled"%>>male<br>
<p>
<b>Comment:</b>
<TEXTAREA NAME="Comment" ROWS=5 COL=15><%=Server.HTMLEncode(Comment)%></TEXTAREA>
<p>

<p><input type="submit" value="Submit">
</form>



</body>
</html>

Roy Sinclair
03-19-2003, 03:29 PM
Do a view-source on the output and see what the generated output looks like. Other than the fact that your code carefully makes sure both radio buttons have the same value (which I would consider to be a bug) you haven't really described what you're seeing.

Abd
03-19-2003, 04:06 PM
Hi,

with regards to the Radio Button what my code return is disabled radio button

Abdul

Roy Sinclair
03-19-2003, 06:09 PM
So what is it putting where you have value="<%=Server.HTMLEncode(Gender)%>" ?

If it isn't "male" or "female" then you have the source of the problem.