Plug-in Posted May 6, 2012 Share Posted May 6, 2012 Hi I would really appreciate it if you could help me out. Firstly the part of my script I'm having trouble with is just displaying titles of posts that have been put into a database, to display it i've got a while() loop which has the condition of $info = mysql_fetch_assoc($query) and although it's rather obvious I'll explain that the $query variable holds a mysql_query function. Displaying the data from the database is working as expected but at the end of the titles I have an "x" which leads to another page where the entries are 'deleted' but to improve the user interface I've added a button labelled "edit" outside the loop which has this event: onclick=\"if (document.getElementById('del_but').style.visibility=='hidden') document.getElementById('del_but').style.visibility='visible'; else document.getElementById('del_but').style.visibility='hidden';\" src='_imgs/button_edit.png'>\" The elements that hold the id 'del_but' are the 'x' buttons aside the titles which are hidden with the use of the visibility styling but when the edit button is clicked only the first x button shows while the rest remain hidden. I'm not sure how I can solve this so if you have any suggestions for resolutions please respond, also the quotes are cancelled out on the code I provided as they're being echoed out. Thank you in advance Quote Link to comment https://forums.phpfreaks.com/topic/262151-while-loop-javascript-and-ids/ Share on other sites More sharing options...
DavidAM Posted May 6, 2012 Share Posted May 6, 2012 In JavaScript, the ID attribute must be unique across the entire document (web page). When you need to refer to a group of elements (like your "delete" buttons) you can use the CLASS attribute. Quote Link to comment https://forums.phpfreaks.com/topic/262151-while-loop-javascript-and-ids/#findComment-1343477 Share on other sites More sharing options...
Plug-in Posted May 7, 2012 Author Share Posted May 7, 2012 Thank you mate took a bit of extra coding but I got what I was after and learnt a bit more Quote Link to comment https://forums.phpfreaks.com/topic/262151-while-loop-javascript-and-ids/#findComment-1343668 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.