I'm creating a photo gallery admin section. I'm allowing the user to decide which single image they would like to be the gallery image (the image that displays on the list of galleries page). I am using a green box to show which image is currently set as the gallery image, and a red box to show which one's are not selected.
The green box is set as just the image, whereas the red box is a link to select that image. The code I currently have seems to turn all the images into red boxes, but does not turn the currently clicked item green. Here is what I have: [code] $(".main_image").live('click',function(){ var href = $(this).attr('href'); $.get(href); var $rows = $('#main_table tr'); $rows.each(function(){ var $id = $(this).attr('id'); $id = $id.split("_"); $id = $id[1]; $(this).find('.gallery_image').html('<a class="main_image" href="/ admin/galleries/p_makemain/' + $id + '.php"><img alt="" title="Main" style="border: 0pt none;" src="/admin/images/redbox.png" /></a>'); }); $(this).parent().html=("<img src='/admin/images/greenbox.png' alt='' / >"); return false; }); [/code] The table that the html is in is setup as: [code] <table width="95%" id="main_table" cellpadding="0" cellspacing="0" border="0"> <tr> <th colspan="2" align="left">Move</th> <th></th> <th align="left">Name and Description</th> <th></th> <th colspan="2" align="left">Options</th> <th></th> <th align="left">Show/Hide</th> <th></th> <th align="left">Gallery Image</th> </tr> <tr id="photo_1" class="photo"> <td valign="top"> <a href="http://www.hypertextwebdesign.com/admin/galleries/p_moveup/ 1.php" class="moveup" style="display:none;"><img src='/admin/images/ up.gif' style='border:0;margin:0' title='Move Up' alt='' /></a> </td> <td valign="top"> <a href="http://www.hypertextwebdesign.com/admin/galleries/p_movedown/ 1.php" class="movedown"><img src='/admin/images/down.gif' style='border:0;margin:0' title='Move Down' alt='' /></a> </td> <td> </td> <td valign="top"><a href="http://www.hypertextwebdesign.com/admin/ galleries/p_view/1.php" class="image_popup">test photo</a><br />this is a test photo entry. No photo actually exists for this record.</td> <td> </td> <td valign="top"><a href="http://www.hypertextwebdesign.com/admin/ galleries/p_edit/1.php"><img src='/admin/images/edit.gif' style='border:0;margin:0' title='Edit Photo Info' alt='' /></a></td> <td valign="top"><a href="http://www.hypertextwebdesign.com/admin/ galleries/p_delete/1.php" class="delete"><img src='/admin/images/ delete.gif' style='border:0;margin:0' title='Delete Photo' alt='' /></ a></td> <td> </td> <td valign="top" style="text-align:center;"> <a href="http://www.hypertextwebdesign.com/admin/galleries/ p_deactivate/1.php" class="active"><img src='/admin/images/ greenbox.png' style='border:0' title='Active' alt='' /></a> </td> <td> </td> <td valign="top" style="text-align:center;" class="gallery_image"> <img src="http://www.hypertextwebdesign.com/admin/images/ greenbox.png" /> </td> </tr> <tr> <td colspan="11"><hr /></td> </tr> <tr id="photo_2" class="photo"> <td valign="top"> <a href="http://www.hypertextwebdesign.com/admin/galleries/p_moveup/ 2.php" class="moveup"><img src='/admin/images/up.gif' style='border: 0;margin:0' title='Move Up' alt='' /></a> </td> <td valign="top"> <a href="http://www.hypertextwebdesign.com/admin/galleries/p_movedown/ 2.php" class="movedown" style="display:none"><img src='/admin/images/ down.gif' style='border:0;margin:0' title='Move Down' alt='' /></a> </td> <td> </td> <td valign="top"><a href="http://www.hypertextwebdesign.com/admin/ galleries/p_view/2.php" class="image_popup">test photo</a><br />this is a test photo entry. No photo actually exists for this record.</td> <td> </td> <td valign="top"><a href="http://www.hypertextwebdesign.com/admin/ galleries/p_edit/2.php"><img src='/admin/images/edit.gif' style='border:0;margin:0' title='Edit Photo Info' alt='' /></a></td> <td valign="top"><a href="http://www.hypertextwebdesign.com/admin/ galleries/p_delete/2.php" class="delete"><img src='/admin/images/ delete.gif' style='border:0;margin:0' title='Delete Photo' alt='' /></ a></td> <td> </td> <td valign="top" style="text-align:center;"> <a href="http://www.hypertextwebdesign.com/admin/galleries/ p_deactivate/2.php" class="active"><img src='/admin/images/ greenbox.png' style='border:0' title='Active' alt='' /></a> </td> <td> </td> <td valign="top" style="text-align:center;" class="gallery_image"> <a href="http://www.hypertextwebdesign.com/admin/galleries/p_makemain/ 2.php" class="main_image"><img src='/admin/images/redbox.png' style='border:0' title='Main' alt='' /></a> </td> </tr> <tr> <td colspan="11"><hr /></td> </tr> </table> [/code] Please help. I appreciate any and all help