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!

Showing & Hiding Objects

Status
Not open for further replies.

Lbob

Programmer
May 23, 2003
157
GB
Hi

Got another annoying problem that I can't work out how to fix. Basically for each user row, there's an edit & save button. When the edit button is clicked the checkboxes become editable, but I want to hide the edit button and show the save button. Essentially inline editing. I've got most of it working except the hide & show bit, I just get an error.

Any help would be greatly appreciated
Lbob

Here's what I've got ...
<script language="vbscript">
Sub EditDetails(Obj)
iUser = right(Obj.Name, len(Obj.Name) - 3)
if document.frmUser.TxtEditUser.value = 0 then
document.frmUser.elements("ChkUserDetails" & iUser).disabled = false

document.frmUser.TxtEditUser.value = iUser

document.frmUser.elements("Ed" & iUser).style.display = "none;"
document.frmUser.elements("Sv" & iUser).style.display = "block;"
else
msgbox("You must save the current user setting before editing another user")
end if
End Sub


</script>

</HEAD>
<body>

<form name="frmUser" ID="frmUser">
<table width="800" border="0" bordercolor="#ff6702" cellpadding="0" cellspacing="0" >
<tr>
<td>Admin User</td>
<td>User Details</td>
<td> *</td>
<td>*</td>
<td> *</td>
<td> *</td>
<td> *</td>
<td colspan="2">&nbsp;</td>
</tr>
<%

set rs = Server.CreateObject("ADODB.Recordset")

set rs = ListData()

do while not rs.EOF

sHTML = "<tr><td>" & rs("User ") & "</td>"
sHTML = sHTML & "<td><input type='checkbox' name='ChkUser" & rs("user_id")
if rs("User") = True then
sHTML = sHTML & "' Disabled=true Checked></td>"
else
sHTML = sHTML & "' Disabled=true ></td>"
end if

sHTML = sHTML & "<td name='Ed" & rs("user_id") & "’ style='display:block;'><a href='#' onclick='EditDetails(this)' name='Ref" & rs("user_id") & "'><img src='graphics/edit_off.gif' hsrc='graphics/edit_on.gif' border='0' name='imgEdit" & rs("user_id") & “></a></td>"
sHTML = sHTML & "<td name='Sv" & rs("user_id") & "' style='display:None;'><a href='#' onclick='SaveDetails(this)' name='Ref" & rs("user_id") & "' ><img src='graphics/save_off.gif' hsrc='graphics/save_on.gif' border='0' name='imgSave" & rs("user_id") &”></a></td></tr>"
sHTML = sHTML & "<tr><td colspan='8'>&nbsp;</td></tr>"
response.Write sHTML

rs.Movenext
loop
rs.Close

set rs = nothing
set cmd = nothing
%>
<tr><td colspan="8"><input type=text name="TxtEditUser" value=0></td></tr>
</table>
 
Is there some ASP question?

I may have missed it but all I see is above is client-side VBScript... Do all of your users have internet explorer?
 
Ah, sorry now I see the ASP that flips through the recordset... but it looks like you are using client-side code to show/hide the buttons.

Take a look at this little thing below... maybe it will help:
Code:
<html>
  <head>
    <title>Test Page</title>
    <script language="vbscript">
      Sub TestHide(ob)
        'hide the one that was clicked
        ob.style.display = "none"

        'get ref to the other one, the one that wasn't clicked
        dim ob2
        if Left(ob.id, 3) = "Foo" then
          set ob2 = document.getElementById("Bar" & Mid(ob.id, 4))
        else
          set ob2 = document.getElementById("Foo" & Mid(ob.id, 4))
        end if

        'show the one that wasnt clicked
        ob2.style.display = "block"
      End Sub
    </script>
  </head>
  <body>
    <table border=1>
      <tr>
        <td colspan=2> 
          This is a test page.
        </td>
      </tr>
      <tr>
        <td>
          <input type    = button 
                 id      = Foo1 
                 value   = Foo1 
                 onClick = "TestHide me" 
                 style   = "display:block;">
        </td>
        <td>
          <input type    = button 
                 id      = Bar1 
                 value   = Bar1 
                 onClick = "TestHide me" 
                 style   = "display:none;">
        </td>
      </tr>
      <tr>
        <td>
          <input type    = button 
                 id      = Foo2 
                 value   = Foo2 
                 onClick = "TestHide me" 
                 style   = "display:block;">
        </td>
        <td>
          <input type    = button 
                 id      = Bar2 
                 value   = Bar2 
                 onClick = "TestHide me" 
                 style   = "display:none;">
        </td>
      </tr>
      <tr>
        <td>
          <input type    = button 
                 id      = Foo3 
                 value   = Foo3 
                 onClick = "TestHide me" 
                 style   = "display:block;">
        </td>
        <td>
          <input type    = button 
                 id      = Bar3 
                 value   = Bar3 
                 onClick = "TestHide me" 
                 style   = "display:none;">
        </td>
      </tr>
    </table>
  </body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top