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

Conditional content 1

Status
Not open for further replies.

maanton

Programmer
Mar 27, 2005
52
0
0
Hi!
I call some data from a db..the code is the following
Code:
<div id="country_info">
<a href="country_info.asp?ID=<%=(desc.Fields.Item("country_info_id").Value)%>&amp;country_id=<%=(desc.Fields.Item("country_id").Value)%>">LINK</a>
</div>

I also have a field on my db named
Code:
c_info
which format is either YES or NO.

Well, I need the above "div" to be displayed only when the field's record is YES.

Please help me...Thanks in advance
 
is this what you mean...

if desc.Fields.Item("c_info").Value)="YES" then
'display div tag
else
'hide div tag
end if

-DNG
 
So...how am I suppose to implement this on my code?
 
oops...sorry forgot about this thread...try the below example

Code:
<html>
<head>
<script>
function showdiv()
{
   var mydiv = document.getElementById("country_info");
   country_info.style.visibility="";
   country_info.style.display="";
}

function hidediv()
{
   var mydiv = document.getElementById("country_info");
   country_info.style.visibility="";
   country_info.style.display="none";
}

</script>
</head>
<body>
<div id="country_info">
<a href="country_info.asp?ID=<%=(desc.Fields.Item("country_info_id").Value)%>&amp;country_id=<%=(desc.Fields.Item("country_id").Value)%>">LINK</a>
</div>

if desc.Fields.Item("c_info").Value)="YES" then
showdiv()
else
hidediv()
end if

</body>
</html>

-DNG
 
oops...sorry forgot about this thread...try the below example

Code:
<html>
<head>
<script>
function showdiv()
{
   var mydiv = document.getElementById("country_info");
   mydiv.style.visibility="";
   mydiv.style.display="";
}

function hidediv()
{
   var mydiv = document.getElementById("country_info");
   mydiv.style.visibility="";
   mydiv.style.display="none";
}

</script>
</head>
<body>
<div id="country_info">
<a href="country_info.asp?ID=<%=(desc.Fields.Item("country_info_id").Value)%>&amp;country_id=<%=(desc.Fields.Item("country_id").Value)%>">LINK</a>
</div>

if desc.Fields.Item("c_info").Value)="YES" then
showdiv()
else
hidediv()
end if

</body>
</html>

-DNG
 
I get this error..
Code:
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'hidediv'
/dumsot/air_desc.asp, line 219
 
the code i posted is free-hand written..so please check for syntax errors before testing...anyways try this:

Code:
<html>
<head>
<script>
function showdiv()
{
   var mydiv = document.getElementById("country_info");
   mydiv.style.visibility="";
   mydiv.style.display="";
}

function hidediv()
{
   var mydiv = document.getElementById("country_info");
   mydiv.style.visibility="";
   mydiv.style.display="none";
}

</script>
</head>
<body>
<div id="country_info">
<a href="country_info.asp?ID=<%=(desc.Fields.Item("country_info_id").Value)%>&amp;country_id=<%=(desc.Fields.Item("country_id").Value)%>">LINK</a>
</div>

<%if desc.Fields.Item("c_info").Value)="YES" then%>
<script>
showdiv()
</script>
<%else%>
<script>
hidediv()
</script>
end if

</body>
</html>

-DNG
 
Thank you sooo much for your effort :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top