Hi All
I have a form that displays stock code information.
I also have an imge that a user chsould click that submits the form and deletes the chosen product.
As follows:
<a href="javascript:delete_item(<?php echo addslashes($stocklist[0]); ?>)";>
<img src="images/remove.gif" alt="Delete Product from Stocklist" width="23" height="20" border="0" />
</a>
I cannot use GET as I do not want info on address bar. So I figured I'd pass the Code in a php variable to the Javascript fucntion as above. The javascript function is as follows:
<script type="text/JavaScript">
<!--
function delete_item(delcode)
{
delcode = (delcode).toString();
if (confirm("Do you really want to delete this item? (OK = Yes Cancel = No)"))
{
document.update.task.value = "remove_item";
alert(delcode);
document.update.code.value = delcode;
document.update.submit();
}
}
//-->
</script>
It may not be the most effective/efficient code but I am stuck for the following reasons:
If the sotckcode is as follows: 612713 the deletion works fine
But if it is like this 035616 or AMS/PF/45 I get a javascritp undefined error.
Can you help or suggest PHP to javscript string conversion. It appears that if the string has leading 0's or starts with a letter it will not work??
Totally confused...
Thanks for all yrou help,
Fergal