Jump to content

print infomation


westman

Recommended Posts

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...