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

checkbox syntax 1

Status
Not open for further replies.

JohannIcon

Programmer
Sep 3, 2002
440
MT
Hi All,

How can I arrange the syntax of this checkbox statement?

response.Write &quot;<input <% if rs1.Fields.Item(&quot;menuActive&quot;).value = &quot;1&quot; Then Response.write(&quot; checked&quot;) : Response.Write(&quot;&quot;)%> name=menuCheck&quot; & n+1 & &quot; type=checkbox id=menuCheck value=&quot; & rs1(&quot;menuID&quot;) & &quot;>&quot;
 
dim sText
if rs1.Fields.Item(&quot;menuActive&quot;).value = &quot;1&quot; then
sText = &quot; checked&quot;
else
sText = &quot;&quot;
response.Write &quot;<input&quot; & sText &&quot; name=menuCheck&quot; & n+1 & &quot; type=checkbox id=menuCheck value=&quot; & rs1(&quot;menuID&quot;) & &quot;>&quot;
 
This is how I would write it
Code:
<%
response.Write &quot;<input&quot;
if rs1.Fields.Item(&quot;menuActive&quot;).value = &quot;1&quot; Then Response.write &quot; checked&quot; 
Response.Write &quot; name=menuCheck&quot; & n+1 & &quot; type=checkbox id=menuCheck&quot; & n+1 & &quot; value=&quot; & rs1(&quot;menuID&quot;) & &quot;>&quot;
%>
Thanks,

Gabe
 
JohannIcon,

You may want to update your code to keep the &quot;name&quot; and &quot;id&quot; attributes the same. You change the &quot;name&quot; attribute but leave the &quot;id&quot; attribute the same.

Thanks,

Gabe
 
If you are not going to keep them in sync, why use both? Why not just use name or id?
Thanks,

Gabe
 
Good Point Gabe. Missed that one.

I have another way for the code. I wrote my own iif function since vbscript is lacking one.

function iif(i_Expr, i_True, i_False)
if i_Expr then
iif = i_True
else
iif = i_False
end if
end function

response.Write &quot;<input&quot; & iif(rs1.Fields.Item(&quot;menuActive&quot;).value = &quot;1&quot;,&quot; checked&quot; , &quot;&quot; )&&quot; name=menuCheck&quot; & n+1 & &quot; type=checkbox id=menuCheck value=&quot; & rs1(&quot;menuID&quot;) & &quot;>&quot;
 
I have to use both cause then I need to do some insertion into different tables depending on these names
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top