Go Back   PCMech Forums > Help & Discussion > Web Design / Development

Need Some Help? Type Your Keywords Here:

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 02-13-2012, 03:44 PM   #1
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
javascript help

Hey guys, Im trying to make a random URL script for my webpage. Basically I want a random link to be displayed everytime the page is loaded. This is what I have but it is not showing up with anything on the website. What am I doign wrong? Im not very good with javascript, if you cant tell...

I couldnt add it to my post without it messing with things so I put it in a text file.
Attached Files
File Type: txt javascript.txt (503 Bytes, 18 views)
__________________
Eric
Help save lives! Click Here
AMD 4800+ X2 @ 2750Mhz (250 x 11) | DFI LanParty UT CFX3200 | 2GB Mushkin pc4000 3-3-2-8 1:1
Sapphire X1900GT 256MB | (2) 150GB Raptors RAID0 | WD 320GB
enhanced08 is offline   Reply With Quote
Old 02-13-2012, 06:57 PM   #2
Member (2 bit)
 
Clutch X's Avatar
 
Join Date: Jan 2012
Posts: 2
Try swapping the ' and " around in the document.write statement. for example: ("some text"+ variable +"more text"); instead of ('text"'+variable+'"more text'); or escape the double quotes like this: \"

Last edited by Clutch X; 02-13-2012 at 07:08 PM.
Clutch X is offline   Reply With Quote
Old 02-13-2012, 08:12 PM   #3
Member (10 bit)
 
strollin's Avatar
 
Join Date: Jan 2010
Location: N. Calif.
Posts: 529
Make sure all of your left parens ( have a matching right paren ). You have 4 lefts but only 2 rights in the line where you assign a value to random_num.
__________________
Been using, building, repairing and programming computers for nearly 30 years now.
strollin is offline   Reply With Quote
Old 02-16-2012, 05:11 PM   #4
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
i tried the suggestions and still can not get it to work. nothing is displayed at all.
enhanced08 is offline   Reply With Quote
Old 02-16-2012, 05:43 PM   #5
Barefoot on the Moon!
Staff
Premium Member
 
Force Flow's Avatar
 
Join Date: Aug 2002
Location: Northeastern USA
Posts: 13,385
Fixed and attached. Just rename the file and get rid of the .txt extension to run it in your browser as a webpage.

There were a few minor errors.

There was an extra space in one of the script tags.

The math library needs to be capitalized.

I also included a new formula for generating the random array index. With this new formula, you can specify the range you want to use.

If you use single-quote strings, you don't need to escape anything but a single quote. If you use double-quote strings, there's a handful of special characters you have to escape. Usually, when you're writing HTML within strings, it's best to use single-quotes because there are fewer symbols you need to escape.
Attached Files
File Type: txt jstest.htm.txt (626 Bytes, 9 views)
__________________
There are two secrets to staying young, being happy, and achieving success. You have to laugh and find humor every day, and you have to have a dream.
Force Flow is offline   Reply With Quote
Old 02-18-2012, 10:12 AM   #6
Foldin' For PCMech!
 
enhanced08's Avatar
 
Join Date: Jun 2003
Location: back home in McHenry MD
Posts: 1,657
Send a message via AIM to enhanced08 Send a message via MSN to enhanced08
Thank you Force, that did the trick!
enhanced08 is offline   Reply With Quote
Reply

Bookmarks

Still Need Help? Type Your Keywords Here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

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



All times are GMT -5. The time now is 07:49 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
SEO by vBSEO 3.6.0 PL2