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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.