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!

dynamic field into table

Status
Not open for further replies.

stpmtp

MIS
Jan 6, 2006
67
US
I am building a form that has some check boxes static text and dates.
New to ASP.
I can do this to see if the box is checked or not
Code:
  <input name="statuson" type="checkbox" <%If rsone.Fields("statuson").Value =false then  Response.Write "unchecked" else Response.Write "checked"  End If %> >[\code]
but could I do if the box is checked then get the value of a static field?
 
I can do this to see if the box is checked or not
Huh???

Assuming the following checkbox is contained within an HTML form:[tt]
<input name="statuson" type="checkbox">[/tt]

*** Before the form is submitted, you could check its value in client-side code (not ASP)[tt]
if (document.forms["MyFormName"].elements["statuson"].checked == true)
{ /* checked */ }
else
{ /* not checked */ }[/tt]



*** An ASP that processes a submitted HTML form might detect if a checkbox was checked like this:[tt]
IF (Len(Request.Form("statuson")) > 0) THEN
'checked
ELSE
'not checked
END IF[/tt]
Note: By default the browser will send the value "on" for all checkboxes that were checked. There is no corresponding "off" for unchecked boxes, merely an absence of "on."



*** If the value of a field named Foo in a database table determines the default status of a checkbox.... and you have read that value into an ADO recordset object named rsone then you could use ASP like below to create HTML that has the proper default checked status:[tt]
Response.Write "<input name=statuson type=checkbox"
If rsone.Fields("Foo").Value then
Response.Write " checked>"
Else
Response.Write ">"
End If [/tt]
Note: There is no "unchecked", just the absence of "checked"


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top