This topic is locked

Enable/Disable DELETE Button

3/12/2009 2:09:55 PM
ASPRunnerPro General questions
R
Roger author

I have a similar issue as this one:

http://www.asprunner.com/forums/index.php?showtopic=11222
However, I do not want to disable the Check Box. If I do so, I cannot Print Selected! I want to be able to disable the Delete Button, when a user clicks on the Check Box if there are child records existing. But I still need to be able to Print Selected.
I suspect this is possible, but I'm not all that sure what the code would look like. I'm thinking some sort of ONCLICK event and a snippet for the checkbox.
I've tried this code snippet as well (modified slightly) from another post - can't find it just now, but it was thru a search:
if Session("SavedValue")<>"" then - I changed session("SavedValue") to something more appropriate for my use

Response.write "<script> $('input[@value="Delete selected"]').get(0).disabled = true; </script>"

end
This code however generates an "Expected End of Statement" error pointing to </script>
If anyone has suggestions I surely would appreciate it.
Roger

Admin 3/12/2009

Double quotes inside ASP strings should be doubled:
Response.write "<script> $('input[@value=""Delete selected""]').get(0).disabled = true; </script>"
Hope this helps.

R
Roger author 3/12/2009

Thanks admin. I tried this, but nothing happens, the button is still enabled.
I removed the condition to make it disabled regardless of any condition as follows:
Response.write "<script> $('input[@value=""Delete selected""]').get(0).disabled = true; </script>"
Nope, I gotta be a yutz, this is pretty simple stuff but it just eludes me., Perhaps the old tired brain...
Roger.

J
Jane 3/13/2009

Hi,
to remove delete button use Before display event.

Here is a sample:

if Session("SavedValue")<>"" then

xt.assign "delete_link",false

end

R
Roger author 3/13/2009

Hi Jane, thanks for the reply.
I am using this code in the "Before Display Event", but nothing happens. The button is still enabled.
if Cint(rs("ServiceRequests")) > 0 then

xt.assign "delete_link",false

end
ServiceRequests (for the most part) are greater than Zero. The only time they would be zero is upon registration or a ServiceRequest item is deleted and the number of request is back to Zero.
I guess what I'm rally looking for is a way to disallow a user from deleting a record if child records exist. In thinking about this, if I do get the above to work, then the delete button would enabled/disabled until the very last record is displayed. Then the condition of that record would determine the result of the delete_link.
So, I'm kinda thinking of something like when a user clicks on the CheckBox for the record (and then clicks on "Delete Selected"), some sort of code (say a popup message) and return to the list. The reasoning here is, is that if they wanted to print selected, they should be allowed to. So, I can't just disable the checkbox (I can make it go away accordingly, but that removes the facility of "Print Selected").
I hope this is sin't too much giberish.
Again, thanks for the assist.
Roger

J
Jane 3/13/2009

Roger,
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

R
Roger author 3/13/2009

Hi again, Jane.
I'm sorry, but I'm not getting any errors at all. I appologize if I gave that impression.
I was just looking for a way to accomplish this. Also, my entire project is MS SQL based and I understand that you need the project to be completely on your system, so I don't think that would work.
Anyway, I'll muddle through this and figure out how to get it to work.
Thanks for the replies and assistance.
Roger. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=39012&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

Admin 3/13/2009

Roger,
don't worry, 'Demo Account' button transfers both files and related database tables to demo server.