Skip to content
Advertisement

prevent the link to open if it contain this condition

Sorry for this question I think it’s not difficult but I’m new to PHP, I tried to show some images of products with the link, If the item is available $row[‘p_status’]==’1′ ok the link will be opened else it display an alert, but I tried to write some code inside while loop but when I test it, it display many alert according the number of those items which is $row[‘p_status’]==’0′ if I have 5 products which it it’s not available if I click on an product it show me five alert.

Please help me this is my code.

JavaScript

Advertisement

Answer

You need an if statement to check if the status is 1. In case it’s 1 you show the link with href otherwise you call the onclick event to display the out of stock alert.

This is one of the solutions (easier for beginners):

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement