Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to pass to assign an variable value to an element

Posted on 2013-01-07
2
Medium Priority
?
159 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 2000 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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…
Suggested Courses

963 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