Newbie : I want to keep showing username & password as an option

T

techy techno

I have 3 fields in my Access DB called URL, Username & password.

I am displaying all the 3 fields on the ASP Page.
What I want is :

I want to show all the fields obvious

BUT

If a particular URL doesn't have a userName and Password then I just
want to
see the URL and the username and password for that URL should not be
diplayed.

thanks
 
R

Ray at

What code are you using to do this? It seems that if you're pulling the
three values from a database, and the two columns are empty, nothing would
be displayed then just as you'd like. Or, do you mean specifically no
username AND no password? If so, something like:

<%
sUsername = rs.fields.item("theUsername").Value
sPassword = rs.fields.item("thePassword").Value
sURL = rs.Fields.Item("URL").Value

If sUsername & sPassword <> "" Then
Response.Write "Your username is " & sUsername & "<br>"
Response.Write "Your password is " & sPassword & "<br>"
End If

Response.Write "The URL is " & sURL
%>

Ray at work
 
T

techy techno

i have a table where I am showing URL, Username, PAss

URL : something
USername : something
password : something

now the thing is that if username and password is empty


it wiil show like this


URL : something
Username :
password :

See I know it will not show the username and pass but the it will show
the HTML text
so what I did is I made 2 HTML table namely : for eg.

TABLE_show = shows all the 3 fields

url_table = only shows the URL


TABLE_show shows all the 3 fields url, Username and password

url_table shows only the URL


now what I need is if username and password exists I want asp code to
show me TABLE_Show

and if the username and pasword doesn't exist I want the asp code to
show me the URL_TABLE


what I wrote is this :


sUsername = rs.fields.item("theUsername").Value
sPassword = rs.fields.item("thePassword").Value
sURL = rs.Fields.Item("URL").Value

If sUserName and sPAssword <> "" THEN
<table>
<tr>
<td>
response.write "Your URL is " & sURL& "<br>"
Response.Write "Your username is " & sUsername & "<br>"
Response.Write "Your username is " & spassword & "<br>"
<td>
</tr>
</table>

<% ELSE %>

<table>
<tr>
<td>
response.write "Your URL is " & sURL& "<br>"
<td>
</tr>
</table>
<% END IF %>
 
R

Roland Hall

:

: See I know it will not show the username and pass but the it will show
: the HTML text
: so what I did is I made 2 HTML table namely : for eg.
:
: TABLE_show shows all the 3 fields url, Username and password
: url_table shows only the URL
: now what I need is if username and password exists I want asp code to
: show me TABLE_Show
: and if the username and pasword doesn't exist I want the asp code to
: show me the URL_TABLE
: what I wrote is this :
: sUsername = rs.fields.item("theUsername").Value
: sPassword = rs.fields.item("thePassword").Value
: sURL = rs.Fields.Item("URL").Value
: If sUserName and sPAssword <> "" THEN
: <table>
: <tr>
: <td>
: response.write "Your URL is " & sURL& "<br>"
: Response.Write "Your username is " & sUsername & "<br>"
: Response.Write "Your username is " & spassword & "<br>"
: <td>
: </tr>
: </table>
: <% ELSE %>
: <table>
: <tr>
: <td>
: response.write "Your URL is " & sURL& "<br>"
: <td>
: </tr>
: </table>
: <% END IF %>

dim szURL, szUN, szPW ' --- url, username and password strings
dim tTop, tBot ' --- table top, table bottom
dim szTable ' --- table string

sUsername = rs.fields.item("theUsername").Value
szUN = "Your username is "
sPassword = rs.fields.item("thePassword").Value
szPW = "Your password is "
sURL = rs.Fields.Item("URL").Value
szURL = "Your URL is "
tTop = "<table><tr><td>"
tBot = "</td></tr></table>"

If sUserName and sPassword <> "" Then
szTable = tTop & szURL & sURL & "<br />" & szUN & sUsername & "<br />" &
szPW & spassword & "<br />" & tBot
else
szTable = tTop & szURL & sURL & "<br />"
end if

Response.Write(szTable)

However, this would be easier on the client-side:

<script type="text/javascript">
function untest() {
if('<%sUsername%>' == '' && '<%sPassword%>' == '') {
} else {
document.getElementById('2').style.display='block';
document.getElementById('3').style.display='block';
}
}
</script>

<body onload="untest()">

<table><tr><td>
<div id=1>Your URL is <%=sURL%></div>
<div id=2 style="display: none">Your username is <%=sUsername%></div>
<div id=3 style="display: none">Your password is <%=sPassword%></div>
</td></tr></table>

--
Roland

This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose.
-Technet Knowledge Base-
http://support.microsoft.com/default.aspx?scid=fh;EN-US;kbhowto&sd=TECH&ln=EN-US&FR=0
-Technet Script Center-
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp
-MSDN Library-
http://msdn.microsoft.com/library/default.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top