Solved

How to pass to assign an variable value to an element

Posted on 2013-01-07
2
148 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
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

930 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now