TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-03-2008, 05:38 AM   #1 (permalink)
The Addict
 
sarmenhb's Avatar
 
Join Date: Jan 2008
Location: los angeles
Posts: 309
Thanks: 44
sarmenhb is on a distinguished road
Default how would i echo this javascript variable

i'm trying to echo this variable to the screen

Code:
thumbs = document.getElementById("thumbnailPane").getElementsByTagName("img");
the way i am echoing the value out is i have a div named output so i did

Code:
document.getElementById('output').innerHTML = 'field: ' + thumbs;
but when i did that i get this

Code:
field: [object HTMLImageElement]
is there another way of doing it?

here is the whole peice of js code i'm using if ur interested.

Code:
window.onload = initPage;

function initPage() {
  
  thumbs = document.getElementById("thumbnailPane").getElementsByTagName("img");

  
  for (var i = 0; i < thumbs.length; i++) {
    image = thumbs[i];
	
	//myoutput:
	document.getElementById('output').innerHTML = 'field: ' + thumbs;

    image.onclick = function() {
    
      detailURL = 'images/' + this.title + '-detail.jpg';
      document.getElementById("itemDetail").src = detailURL;
	  
      getDetails(this.title);
	  
    }
  }
}
i also tried doing thumbs[i] and echoing the image variable but it shows the same output.
__________________
no signature set
sarmenhb is offline  
Reply With Quote
Old 12-03-2008, 02:06 PM   #2 (permalink)
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

That's the correct behaviour because thumbs is an object. As JavaScript is very OOP. So you will need to access its methods. Such as like to get the actual SRC of the image, use the following:

javascript Code:
var source = thumbs.getAttribute('src');
alert("Image's Source is: " + source);
__________________
Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
Karl is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Advance Pagination Class Rendair Advanced PHP Programming 13 02-01-2013 11:08 AM
Easily Format JSON using PHP and Interpret using Javascript Wildhoney Advanced PHP Programming 13 02-01-2013 11:05 AM
[Tip] Variable Prefixes bluesaga Tips & Tricks 24 10-22-2012 09:40 AM
What is a Variable? codefreek Absolute Beginners 7 07-01-2008 08:29 PM
My dynamic menu lesP Advanced PHP Programming 7 01-21-2008 10:28 PM


All times are GMT. The time now is 10:58 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design