westman Posted November 24, 2013 Share Posted November 24, 2013 Hi all, I am trying to get my code to print information to the page (an image) this is what i have PHP (in while loop) $item_pic = '<a title="Edit" style="text-decoration:none;" href="#" onclick="return false" onmousedown="javascript:toggleSection('20'); javascript:edit_item_id('5');"><img src="' . $check_prod_pic . '" width="50px" border="0" /></a>'; JavaScript / jQuery <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script><script type="text/javascript">function edit_item_id(itemid) {var theitemid = itemid;out_edit_item_pic1 = document.getElementById("edit_item_pic1");out_edit_item_pic1.innerHTML = code working;/*out_edit_item_pic1.innerHTML = '<img src="../images/items/'.theitemid.'/pic1.jpg" width="200px" border="0" />';*/}</script> HTML <div id="edit_item_pic1"></div> it is not working, any help? Link to comment Share on other sites More sharing options...
davej Posted November 24, 2013 Share Posted November 24, 2013 Describe how it's supposed to work. Link to comment Share on other sites More sharing options...
westman Posted November 25, 2013 Author Share Posted November 25, 2013 when a php picture link is clicked the javascript should run and print "code working" in my div one that works I will then try to get javascript to print a picture as the final step. Link to comment Share on other sites More sharing options...
Hadien Posted November 25, 2013 Share Posted November 25, 2013 first off: out_edit_item_pic1.innerHTML = code working; doesn't work because "code working" wasn't in quotes so it not seen as a string. As for. out_edit_item_pic1.innerHTML = '<img src="../images/items/'.theitemid.'/pic1.jpg" width="200px" border="0" />'; you're using php's string concatenation in javascript. use a '+' not '.'. also try to define a height Link to comment Share on other sites More sharing options...
westman Posted November 25, 2013 Author Share Posted November 25, 2013 thank you Hadien "code working" is now working but how do I add that "theitemid" variable in my image? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 25, 2013 Share Posted November 25, 2013 out_edit_item_pic1.innerHTML = '<img src="../images/items/'+theitemid+'/pic1.jpg" width="200px" border="0" />'; Link to comment Share on other sites More sharing options...
westman Posted November 26, 2013 Author Share Posted November 26, 2013 thank you so much. It is now working well again Thank you Link to comment Share on other sites More sharing options...
westman Posted November 27, 2013 Author Share Posted November 27, 2013 one last think...My .value is not working function edit_item_pic1(itemid) {var theitemid = itemid; /* working *//*var theitemid1 = $("#itemid");*/out_edit_item_pic1 = document.getElementById("edit_item_pic1"); /* working */out_edit_item_pic_hidden1 = document.getElementById("edit_item_image1_hidden"); /* not working */out_edit_item_pic_hidden1.value = theitemid; /* not working *//*out_edit_item_pic_hidden1.value = theitemid1.val();*/out_edit_item_pic1.innerHTML = '<img src="../images/items/'+theitemid+'/pic1.jpg" width="200px" height="200" border="0" /><div align="center"><a href="index.php?item=remove&picitemid='+theitemid+'&pic=1">Remove</a></div>'; /* working */} any help? Link to comment Share on other sites More sharing options...
Hadien Posted November 27, 2013 Share Posted November 27, 2013 it appears that the problem is elsewhere and not in that code snippet. its likely that an element with an id "edit_item_image1_hidden" doesn't exist on that page. check the code thats adding the element (if its javascript adding the element) and setting the id. Link to comment Share on other sites More sharing options...
westman Posted November 27, 2013 Author Share Posted November 27, 2013 thank you found it. it was a php problem Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now