M
Max
I'm reading some files in a directory using php code for the end result of
allowing these files to be deleted.
The problem is some of the file names have hyphens in them, and this cannot
be changed.
The php code prints each file name on a page and has a delete link for each
seperate file. I pass the name of the file via a variable using onclick to a
javascript confirm function when the delete link is clicked on. But when the
javascript confirm dialog box appears and asks 'Are you sure you want to
delete file xxxx', if the file name was for example 120-01, the javascript
dialog would display will display 119 instead.
How can I get around this? I started to read something about using brackets,
but I can't seem to get it working.
Here is the relevant code:
Let's say $id[0] = "120-01";
print " <td style=\"background-color:silver\" width=\"5%\"
align=\"center\"><b><a href=\"JavaScript:confirm_entry($id[0],$dir_count
\">Delete</a></b></td>";
<script language=\"JavaScript\">
function confirm_entry(id,dir_count) {
input_box=confirm(\"Are you sure you want to delete MTR ID \"+id+\" ?\");
if (input_box==true) {
window.location = \"$self?delete=\"+id+\"?dircount=\"+dir_count
}
}
</script>
The confirm will end up as "Are you sure you want to delete MTR ID 119 ?"
and likewise the postback variable will be 119 instead of 120-01.
Any suggestions?
Thanks,
Max
allowing these files to be deleted.
The problem is some of the file names have hyphens in them, and this cannot
be changed.
The php code prints each file name on a page and has a delete link for each
seperate file. I pass the name of the file via a variable using onclick to a
javascript confirm function when the delete link is clicked on. But when the
javascript confirm dialog box appears and asks 'Are you sure you want to
delete file xxxx', if the file name was for example 120-01, the javascript
dialog would display will display 119 instead.
How can I get around this? I started to read something about using brackets,
but I can't seem to get it working.
Here is the relevant code:
Let's say $id[0] = "120-01";
print " <td style=\"background-color:silver\" width=\"5%\"
align=\"center\"><b><a href=\"JavaScript:confirm_entry($id[0],$dir_count
\">Delete</a></b></td>";
<script language=\"JavaScript\">
function confirm_entry(id,dir_count) {
input_box=confirm(\"Are you sure you want to delete MTR ID \"+id+\" ?\");
if (input_box==true) {
window.location = \"$self?delete=\"+id+\"?dircount=\"+dir_count
}
}
</script>
The confirm will end up as "Are you sure you want to delete MTR ID 119 ?"
and likewise the postback variable will be 119 instead of 120-01.
Any suggestions?
Thanks,
Max