navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Javascript set text in HTML element

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> Microsoft FrontPage Help >> Javascript set text in HTML element
Page: [1]
 
FlowerPower

 

Posts: 67
Joined: 4/27/2004
Status: offline

 
Javascript set text in HTML element - 4/27/2004 19:28:27   
Greetings - first post here...

This may not be a true newbie question, but then I don't feel that experienced still, so I'll ask it here anyway. I have a page where I want to display a random quote on the index page when it opens in the browser. I have made a javascript function that is called in the <body onload> tag. It generates a random number and runs a switch sentence to select from a pool of quotes and depending on the case sets one of these quotes as the text of a string variable. This all works well.

The problem is that I then want to display this text in a particular location, e.g. a <p> or <div> or <span> or <table>. I'd rather not use a form element, as a textbox or similar would clash with the look of the page. I don't know how to specify that the string variable should be displayed in the HTML element. document.write overwrites the rest of the stuff in the page (it's a menu sidebar in a frames page, and I have a DHTML pulldown menu higher up on this page - I want to display the quote below the menu).

Any ideas will be received gratefully!
FlowerPower :o)
BobbyDouglas

 

Posts: 5456
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: Javascript set text in HTML element - 4/27/2004 19:30:27   
Welcome to Outfront! Can you use PHP or ASP to create this? Or must you stick with JavaScript?

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to FlowerPower)
FlowerPower

 

Posts: 67
Joined: 4/27/2004
Status: offline

 
RE: Javascript set text in HTML element - 4/27/2004 20:35:03   
Hi, thanks for your speedy reply.

Um, I guess I could use ASP. The web server I use does not support PhP, but I know I could use ASP. Better get my book out and peruse that chapter on ASP...

I was hoping there was a quick and easy way in JavaScript of naming a specific tag (something along the lines of <p id="quote"> and then setting the value of the element with that name. I searched google for quite a while though and came up with nothing I could use, so began to suspect that maybe I would have to use something other than JavaScript.

Thank yoy!
FlowerPower

(in reply to BobbyDouglas)
BobbyDouglas

 

Posts: 5456
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: Javascript set text in HTML element - 4/27/2004 20:41:39   
Well it is a little bit easier than you will expect:

http://www.expinion.net/software/app_quote.asp
http://www.digiappz.com/freekot2.asp?id=6

If you are just starting ASP you might want to check out some free scripts to see how others use ASP @ www.hotscripts.com

Show us the link once you get it set up :)

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to FlowerPower)
FlowerPower

 

Posts: 67
Joined: 4/27/2004
Status: offline

 
RE: Javascript set text in HTML element - 4/27/2004 20:56:03   
Thanks!
I've dabbled in PhP and have programmed quite a bit in VB before, so ASP is not a big problem to get used to.

As for the link, the site won't be up for another month and a half yet - it's a site for my high school IT students, and will be replacing the site I currently have up, but I'll wait till the end of the semester before I do the switch.

FP:)

(in reply to BobbyDouglas)
FlowerPower

 

Posts: 67
Joined: 4/27/2004
Status: offline

 
RE: Javascript set text in HTML element - 4/28/2004 19:38:11   
Thanks, got it working with a tiny bit of ASP. I have put it up for testing, but there are no links going to it yet, as it is not intended to be put into use for another couple of months. Here's what's up so far:

http://community.ismanila.com/staff/brokvams/web0405/index.htm

FlowerPower :)

(in reply to BobbyDouglas)
BobbyDouglas

 

Posts: 5456
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: Javascript set text in HTML element - 4/28/2004 20:31:46   
Yikes!! That pages takes forever to load.

The quote looks very nice though :)

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to FlowerPower)
puiwaihin

 

Posts: 1378
From: Taiwan
Status: offline

 
RE: Javascript set text in HTML element - 4/30/2004 14:31:21   
To do that in Javascript you would need to open the document first. So after the <body> tag write <script language="javascript">document.open()</script> and then when you use the document.write() function the page will not get overwritten.

_____________________________

" Things are always darkest, just before it goes totally black."
-Hannibal Smith

(in reply to BobbyDouglas)
FlowerPower

 

Posts: 67
Joined: 4/27/2004
Status: offline

 
RE: Javascript set text in HTML element - 5/2/2004 6:50:21   
Strange. The entire site takes up 400 KB as far as I can see, although the web folder is placed inside a larger (FrontPage web) folder containing the site I'm using this school year. Would this larger site be loaded into memory as well, even if those pages are not actually visible in the browser? Or could the considerable loading time be due to a slow web server. The server belongs to the school I work for, and probably has rather limited specs...

FP

(in reply to BobbyDouglas)
BobbyDouglas

 

Posts: 5456
Joined: 5/15/2003
From: Arizona
Status: offline

 
RE: Javascript set text in HTML element - 5/2/2004 12:53:13   
Would this larger site be loaded into memory as well, even if those pages are not actually visible in the browser?
- Browsers only load the code, and any coorsponding tags in the code that inserts something else (ie the external javascript files/external CSS)

Or could the considerable loading time be due to a slow web server.
- It was prolly a slow server at the time. Loads fine for me now. :)

_____________________________

Arizona Web Design - Mr Bobs Web Design in Arizona
The Arizona Web Hosting Challenge

(in reply to FlowerPower)
Page:   [1]

All Forums >> Web Development >> Microsoft FrontPage Help >> Javascript set text in HTML element
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts