SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Dec 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Looking For a JavaScript

    I've looked around for this javascript and can't find one that does all that I wish.

    I would like to have a button that when clicked by a visitor would
    display a line of text (that could be clicked as a hotlink) in a size
    '60' text box. The line of text would be random and one of a group of about 100 different 'texts'.

    I have found random quote jscripts, but I also need hot link capability and the refresh by button instead of refreshing the whole page.

    Any ideas?

    Thanks.

    Rick

  2. #2
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does it have to appear in a textbox? Why not just have a link someplace on the page?

    Users aren't accustomed to clicking on textboxes for a link. Is this how you want it, or do you think it has to be done that way?
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  3. #3
    SitePoint Member
    Join Date
    Dec 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm open to another approach. I just thought
    that the info would be more visible from the rest of the page by being in a text box.
    Maybe the color of the text could be changed to make it more visible?
    I just don't want to have to refresh the page for the link to change.

  4. #4
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    	<title>Test</title>
    	<script type="text/javascript">
    	
    		function makeRandomLink( linkId )
    		{
    			var links = [
    				['http://www.peterbailey.net/','Peter Bailey\'s Website'],
    				['http://www.codingforums.com/','CodingForums'],
    				['http://www.google.com/','Google search-engine']
    				];
    			var link = document.getElementById( linkId );
    			var newLink = links[Math.floor( Math.random() * links.length )];
    			link.href = newLink[0];
    			link.firstChild.nodeValue = newLink[1];
    		}
    	
    	</script>
    </head>
    <body>
    	<input type="button" value="Random Link" onclick="makeRandomLink('randLink')"/>
    	<a href="http://www.peterbailey.net/" id="randLink">Peter Bailey's Website</a>
    </body>
    </html>
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  5. #5
    SitePoint Member
    Join Date
    Dec 2002
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks beetle/peter!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •