Jump to content

While Loop, Javascript and IDs


Plug-in

Recommended Posts

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 :)

Link to comment
https://forums.phpfreaks.com/topic/262151-while-loop-javascript-and-ids/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.