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

Hide list item with VBScript?

Status
Not open for further replies.

tektipster79

Programmer
Oct 1, 2007
34
US
I don't do much VBScript programming, I have some VBScript in an ASP page.
I need to request the value of a server variable which I have done:

Sub GetRoles
dim decryptedRoles
decryptedRoles = Decode(Request.ServerVariables("HTTP_ROLES"))
GetRoles = decryptedRoles
End Sub

Then, based on the return value of this method, I need to hide a list item:

<ul>
<li id="hide"></li>
</ul>

Something like I would do in Javascript like:
var elem = document.getElementById("hide");
elem.style.display = 'none';

Can I do this?
 
[tt]<% if GetRoles="whatever" then %>
<li id="hide">...</li>
<% else %>
<li id="hide" style="display:none;">...</li>
<% end if %>[/tt]
 
Sorry I forgot the most important part. I don't have access to the list items "before" the fact unfortunately. They come from a database and then the code Response.Writes them out to the page. I've gotten to this part so far,

<%
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open("***")

sSQL = "SELECT listitems FROM Template where id = 1"
Set oRecordSet = oConnection.Execute(sSQL)

While Not oRecordSet.EOF
Response.Write(oRecordSet("listitems"))
oRecordSet.MoveNext
Wend

Set oRecordSet = Nothing
oConnection.Close
Set oConnection = Nothing

Function GetRoles
dim decryptedRoles
decryptedRoles = "hide"
GetRoles = decryptedRoles
End Function

%>

<script type="text/vbscript">
if <% = GetRoles = "hide" %>
Document.GetElementById("hide").Style.Display = "none"
end if
</script>

Am I doing this the right way?
 
[tt]<script type="text/javascript">
function y() {
if ("<% =GetRoles %>"== "hide") {
Document.getElementById("hide").style.display = "none";
}
}
window.onload=y;
</script>[/tt]
You might come back and say you forgot to say GetRoles got to be more complicated.
 
correction
Forgotten to change the case of this word.
[tt] [red]d[/red]ocument.getElementById("hide").style.display = "none";[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top