ivytony Posted March 14, 2008 Share Posted March 14, 2008 I put this piece of code in the <head> part: <script> function confirmDelete(delUrl,name_cat) { if (confirm("Are you sure you want to delete category "" name_cat ""nfrom the database")) { document.location = delUrl; } } </script> In the hyperlink, I did this: <a href="javascript:confirmDelete('manage_category.php?what=delete&catID={$cat_ID}','{$cat_name}')" >Delete</a> Right now, this javascript doesn't respond at all. I am wondering what is wrong? Quote Link to comment https://forums.phpfreaks.com/topic/96185-my-javascript-doesnt-work-pls-help/ Share on other sites More sharing options...
paul2463 Posted March 14, 2008 Share Posted March 14, 2008 try this <a href="javascript:confirmDelete('manage_category.php?what=delete&catID='<?php echo $cat_ID; ?>','<?php echo $cat_name; ?>')" >Delete Quote Link to comment https://forums.phpfreaks.com/topic/96185-my-javascript-doesnt-work-pls-help/#findComment-492374 Share on other sites More sharing options...
ivytony Posted March 14, 2008 Author Share Posted March 14, 2008 thanks, actually I did include <?php ?> in my links, but I forgot to include php tags in my post. sorry Quote Link to comment https://forums.phpfreaks.com/topic/96185-my-javascript-doesnt-work-pls-help/#findComment-492379 Share on other sites More sharing options...
paul2463 Posted March 14, 2008 Share Posted March 14, 2008 try the <a href="javascript:confirmDelete('manage_category.php?what=delete&catID='<?php print $cat_ID ?>','<?php print $cat_name ?>')" >Delete instead of echo Quote Link to comment https://forums.phpfreaks.com/topic/96185-my-javascript-doesnt-work-pls-help/#findComment-492383 Share on other sites More sharing options...
ivytony Posted March 14, 2008 Author Share Posted March 14, 2008 thanks, I tried print, but it doesn't seem to work. Here's an actual link: javascript:confirmDelete('manage_category.php?what=delete&catID=4','Electronics') cannot figure out why it doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/96185-my-javascript-doesnt-work-pls-help/#findComment-492397 Share on other sites More sharing options...
fenway Posted March 14, 2008 Share Posted March 14, 2008 That if() line has syntax errors. Quote Link to comment https://forums.phpfreaks.com/topic/96185-my-javascript-doesnt-work-pls-help/#findComment-492406 Share on other sites More sharing options...
ivytony Posted March 14, 2008 Author Share Posted March 14, 2008 how do I correct it? thanks! I think the problem is in the name_cat part. Quote Link to comment https://forums.phpfreaks.com/topic/96185-my-javascript-doesnt-work-pls-help/#findComment-492411 Share on other sites More sharing options...
paul2463 Posted March 14, 2008 Share Posted March 14, 2008 if a function does nothing then it doesnt normally like the function , try this one function confirmDelete(delUrl,name_cat) { if (confirm("Are you sure you want to delete category " + name_cat + "nfrom the database")) { document.location = delUrl; } } Quote Link to comment https://forums.phpfreaks.com/topic/96185-my-javascript-doesnt-work-pls-help/#findComment-492417 Share on other sites More sharing options...
ivytony Posted March 14, 2008 Author Share Posted March 14, 2008 thank you all so much! It finally works in the way it's supposed to be. appreciate the help Quote Link to comment https://forums.phpfreaks.com/topic/96185-my-javascript-doesnt-work-pls-help/#findComment-492432 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.