zq29 Posted September 21, 2006 Share Posted September 21, 2006 I have a list of thumbnail images in a scrolling div, that when clicked, I'd like the large version of the image to load up in another div - I don't want to be passing stuff through the URL so I'm dynamicaly creating forms with the relevent information in hidden fields and submitting it back to itself. Now, it's only working when clicking on the last displayed thumbnail - When clicking on any other thumbnail the FireFox JavaScript debugger is giving me 'document.load_face_16 has no properties' messages (the '16' part varies depending on what image/form was submitted).[code]<div style="overflow:scroll; overflow-x:hidden; height:450px; width:150px; border:1px solid #000; text-align:center;"> <?php $result = mysql_query("SELECT p.`name`, pf.`id` FROM `product` as p, `product_face` as pf WHERE p.`id` = pf.`product_id` AND pf.`default` = '1' ORDER BY `name` DESC") or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { echo "<form name='load_face_$row[id]' action='' method='post'><input type='hidden' name='product_face_id' value='$row[id]'/></form> <img src='../images/product/face/$row[id]_thumb_l.jpg' alt='$row[name]' border='0px' style='padding-bottom:6px;' onclick='document.load_face_$row[id].submit();'/><br/>"; } ?></div>[/code]Considering the last one works, is the last one overwriting something defined in all of the previous ones? Any help is greatly appreciated :) Quote Link to comment Share on other sites More sharing options...
.josh Posted September 21, 2006 Share Posted September 21, 2006 try onclick='document.forms[{document.load_face_$row[id]}].submit();'or possibly without the { } i haven't quite worked out the whole {} part but i think in some browsers you can't just use the form.formname you have to use document.forms[formname] or document.getelementbyid[formname] (with id='formname' in your form tags) Quote Link to comment Share on other sites More sharing options...
zq29 Posted September 21, 2006 Author Share Posted September 21, 2006 Hmmm, thanks Crayon, I'll try that out when I get back in the office. Although, I did try document.forms.load_face_$row[id].submit(); which is similar but there's still a difference. I'll report back once I have tried it. Quote Link to comment 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.