Solved

How to pass to assign an variable value to an element

Posted on 2013-01-07
2
152 Views
Last Modified: 2013-01-22
I have an element and I am trying to pass a variable value of another element. here is my code

var links = document.createElement ('li');
 var img = document.createElement( 'img');
img.src = option.image;  // this gives the path of the image
img.alt = option.prompt;

links.appendChild( img );

var s1 = document.createElement('span');

Open in new window


In the above code I want to display option.prompt  ( the value) in s1. So using createTextNode won't help as it will only display option.prompt but not its value. this is where I am stuck.

any advice or examples are appreciated
0
Comment
Question by:niceoneishere
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 38752844
If I understand this you want the string in option.prompt so:

s1.innerHTML=option.prompt;

if you want the literal option.prompt then

s1.innerHTML='option.prompt';

Cd&
0
 
LVL 1

Author Closing Comment

by:niceoneishere
ID: 38808480
Thanks
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question