JavaScript - Newbie Needs Help With Script
Hi, there. I'm wanting to put a gif on my site that when clicked, will display a random page for the visitor to see next. The gif name is located on my site he image/nextrandombutton.gif
I have the below saved at randomlink.js and have it loaded to my site. But I can't get it to work. <!-- /* Random link button- By JavaScript Kit (http://javascriptkit.com) Over 300+ free scripts! This credit MUST stay intact for use */ //specify random links below. You can have as many as you want var randomlinks=new Array() randomlinks[0]="http://www.bigpileofdogshirts.com/vintageorangecratedogs.htm" randomlinks[1]="http://www.bigpileofdogshirts.com/mikesibley.htm" randomlinks[2]="http://www.bigpileofdogshirts.com/floraldreams.htm" randomlinks[3]="http://www.bigpileofdogshirts.com/pirates.htm" randomlinks[4]="http://www.bigpileofdogshirts.com/ilovemycartoonpupsquares-new.htm" function randomlink(){ window.location=randomlinks[Math.floor(Math.random()*randomlinks.length)] } //--> I've tried all four of the below, but each returns a different error message. <a href="javascript:randomlink.js"><img src="images/nextrandombutton.gif"></a> <a href="javascript:randomlink.()"><img src="images/nextrandombutton.gif"></a> <a href="javascript:randomlink.js()"><img src="images/nextrandombutton.gif"></a> <a href="javascript:randomlink.()"><img border="0" src="images/nextrandombutton.gif"></a> Similar TutorialsHi Everyone, I'm trying to place some script on my website using Dreamweaver. I have been given the script to add a review to our site from another service provider. I get the message "There is a syntax error on line 1..." I am totally unfamiliar with Java and was wondering if someone could check the code for me and tell me where the problem is? Really appreciate any help you can offer. Many thanks Cathal Code: <script type='text/javascript' language='javascript'>document.write(unescape("%3Clink rel='stylesheet' href='http://www.whatclinic.com/css/reva_reviews.css' type='text/css' media='screen' /%3E%3Cscript src='https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' type='text/javascript'%3E %3C/script %3E%3Cscript src='http://www.whatclinic.com/js/flXHR/flXHR.js' type='text/javascript'%3E %3C/script %3E%3Cscript src='http://www.whatclinic.com/js/external_reviews.js' type='text/javascript'%3E %3C/script %3E"));</script><script type='text/javascript' language='javascript'>document.write(unescape("%3Cdiv id='reva_reviewscoreholder' class='provider_all_Reviews'%3E%3C/div%3E%3Cscript type='text/javascript' language='javascript'%3E $(document).ready(function() {reva_showReviewScore_New(103086);});%3C/script %3E"));</script> Hi guys, i am trying to work with google maps api my issue is with creating an array of markers count the number of marker, and then if it equal two, issue an error msg. i wrote some code, but that doesn't work obviously. and my question is how do i write that code in javascript ? GEvent.addListener(map, 'click', function (overlay, latlng) { if (placeMarker.length < 2) { pendingLatLng = latlng; setTimeout("settleClick()", 225) } else { message("You can only select 2 points."); } }); a sample click event which looks like the line below does work. what am i doing wrong ?: google.maps.event.addListener(map, 'click', function (event) {placeMarker(event.latLng); }) How can i go about showing on screen a count from an initial value to an end value over a set time period. Initial value = 0 End value = 2000 Time = 25 seconds I cant find an example of this anywhere, so I'm trying here to see if somebody can help Hello All! Brand new to Javascript here, so please forgive my basic question. I did a search but did not find exactly what I was looking for. My web site has a splash page with a large image broken into pieces and displayed in a table. I want to preload the images so the user doesn't see the table slowly "fill in" when using a slower internet connection. I have written a basic script, using the basic format of: <SCRIPT LANGUAGE="JavaScript"> Image1= new Image(50,60) Image1.src = "something.gif" Image2 = new Image(70,80) Image2.src = "somethingelse" Image3 = new Image(90,100) Image3.src = "lastsomething.gif" </SCRIPT> and saved it as a .js file and placed it in my sites root directory. Just to be safe, I've placed the images there too. (do I have to do that though?) Still, it does not seem to be working. Below is the head from my splash page. Have I missed somthing here? I thought that by putting the script reference in the head, the images would be loaded before the table came up, but such does not seem to be the case. Any help would be most appreciated. Thanks! <html> <head> <title>Finish Well Endurance</title> <meta name="generator" content="Namo WebEditor"> <link type="text/css" rel="stylesheet" href="http://www.fwe1.net/css/index.css"> <script type="text/javascript"language="javascript"src="loadimages.js"></script> </head> <body bgcolor="#464646" text="black" link="#464646" vlink="#464646" alink="#464646"> <table border="0" align="center" cellpadding="0" cellspacing="0" width="600"> Hi All, I have two scripts which I want to try and integrate. I am using a nice gallery script to show thumbnails which are appended to a an image wrapper which on click of the thumbnail shows the larger image in the image wrapper, I am trying to implement cloud zoom which is a plugin which uses image srcs to then point to an anchor href to show another larger zoom image either in the same place.. which is what I am trying to do or in another div beside. I have had to set me img srcs up in a certain way to easily enter some product details. and I need to try an manipulate the code to make it work to suit my file layout. I am using a var= images [ with a series of file locations and info such as below { src: 'romanticabride/thumbs/tn_Shauna.jpg', srcBig: 'romanticabride/images/Shauna.jpg', title: 'Shauna', longDescription: '<b><H1>Shauna</H1></b><br><b>Romantica Of Devon <br><br><h2>Sizes Available:</h2><br> 6 - 32.<b><br><b><br><b><b><b><H2>Colours Available:</h2><b><br>Various<br>Please Enquire Below<br><br><br><br><a href="mailto:tracy@cherishbridal.co.uk?subject=Web Enquiry Regarding Romantica Shauna Bridal Gown"class="enquiry rose glow" >Click To Enquire About This Item </a>' }, what I need is for cloud zoom to work when the main image wrapper is hovered over which means it will need to add a class or when the whichever srcBig: is hovered over it gets wrapped by href to make the script work . one of my pages is http://www.cherishbridal.co.uk/romaticabride.html the cloud zoom script is at http://www.professorcloud.com/mainsite/cloud-zoom.htm.. I am happy to share a jsfiddle with someone or explain further or post some code. Thank you in advance I have a script that works in seamonkey(my html editor) but when I use it in IE8 it says errors happen. Here's the code (the first line is on line 7 of the html file): Code: <script type="text/javascript"> function enlarge(imageNum) { var numToString = ""; if(parseInt(imageNum) < 10){ numToString = "0" + imageNum; } else { numToString = imageNum + ""; } window.open("images/LgScreenshot"+numToString+".jpg","Screenshot "+imageNum,"status=0,height=675,width=900,resizable=0"); } </script> And the errors: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; GTB0.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.3; .NET CLR 3.0.30729) Timestamp: Wed, 10 Feb 2010 14:58:16 UTC Message: Object expected Line: 150 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html Message: Invalid argument. Line: 18 Char: 1 Code: 0 URI: http://samssc2site.co.cc/Features.html does any expert know how to pass parameters in the <script ..> tag? for instance; Code: <script type="text/javascript" src="script.js ?param1=val1¶m2=val2&etc "> in the javascript script.js, how would we read the params after the question mark? for example, google this; google shopping cart /v2_2/cart.js Hi, I am trying to learn how to use radio buttons in javascript without using functions. This is what I did but it does not work: <script language="javascript"> var season3pointer = "Ray Allen" if (season3pointer == Ray Allen) { alert("Good Answer"); } else { alert("You don't know anything about the Celtics") } document.write("<form action='http://www.nba.com/celtics/' method='post'>"+"<p>"+"Who has the record for most 3 points made in a game?"+ "<br/>"+"<input type='radio' name='game-3-pointer' value='bestrecord'>"+season3pointer+ "Antoine Walker"+"<br />"); </script> I know it should be very easy, but so far I have only found how to do it using functions, any help truly appreciated. Hi - can you please tell me the correct syntax for this please? Both scripts 'CalculateBasic' and 'CalculateTape' both happily return the correct amount - all I want to do is add them up to give me a form.price.value I just can't seem to get the right syntax. <script type="text/javascript"> function CalculateTot(form) { form.price.value = CalculateBasic(form) + CalculateTape(form); } </script> Please can you help Thanx I am trying to create a personal webpage within Frames. The problem is, when I start the left frame, the main frame does what it's supposed to do, but if I click into the mainframe, it opens in an entirely new window, therefore losing my Frameset. I want to be able to visit webpages I have in an Array and be able to use the webpages (surf them, click on links and such). Please forgive the sloppy coding, I am a beginner. This is what I have so far: Frameset: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <frameset cols="220,*" border=5> <frame src="leftFrame.html" name="side" sideborder=1 Scrolling="no" marginwidth="5" marginheight="5" noresize> <frame src="mainFrame.html" name="main" sideborder=1 Scrolling="yes" marginwidth="5" marginheight="5" noresize> </frameset><noframes></noframes> </frameset> <body> </body> </html> Left Frame: Code: <html> <HEAD> <SCRIPT LANGUAGE="JavaScript"> <!-- Begin var page = new Array( "http://google.com" "http://ebay.com" "http://facebook.com" ); var endpage = "/the-end.html"; var slidenum = 0; var slidecount = page.length; var timerID = 0; var show_is_on = 0; var timedelay; var iteration; function showSlideShow() { slidenum++; if (slidenum < slidecount+1) { parent.main.location.href = page[slidenum-1]; document.getElementById('slnum').innerHTML = slidenum } if (slidenum == slidecount+1) { parent.main.location.href = endpage; } else timerID = setTimeout('showSlideShow()', timedelay); } function doShow() { if (!show_is_on) { show_is_on = 1; iteration = document.getElementById('startfrom').value if (iteration > 0) { slidenum = iteration-1 } setTimer(document.getElementById('interval').value); showSlideShow(); } } function stopShow() { clearTimeout(timerID); show_is_on = 0; } function setTimer(milliseconds) { timedelay = milliseconds; } // End --> </script> </HEAD> <P> <form name="form1"> Time delay: <input type="text" size="4" name="interval" id="interval" value="7000" /> <br>(In milliseconds) <P><input type="button" value="Start process" onClick="doShow()" /> <P><input type="button" value="Pause process" onClick="stopShow()" /> <P>Jump to:<input type="text" size="4" name="startfrom" id="startfrom" value="0" /> <P>Progress: <b id="slnum">0</b> of <b id="slcount">0</b> </form> <SCRIPT LANGUAGE="JavaScript"> document.getElementById('slcount').innerHTML = slidecount </SCRIPT> </HEAD> <BODY> </BODY> </html> Main Frame: Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> </body> </html> Thanks in advance! Hello I am new and need some help if possible please. I have a site of which i am putting together for a bit of fun and to teach myself but i need a little help from the masters of script if i may. I have a line of text but need it hidden but whatever i do i cant get it to work. It is on my contact page with HTML & a recaptcha & also a php file. What you see on my site is the following. name then empty field box email address then empty field box subject then field box prefilled with WEB SITE ENQUIRY comments then empty field box. What i would like is for the complete line in BOLD above to be hidden so it cant be seen on the website BUT i can see it when the email is received by me. I am having a bad day by not being able to complete this small task. Any help would be nice if somebody could edit the script for me. Many thanks </script> <div class="email"> <table> </tr> <tr> <td align="justify"> <p align="justify"><label for="name"><b>Name</b> *</label> </td> <td valign="top" align="justify"> <p align="justify"> <input type="text" name="name" maxlength="50" size="40"> </td> <tr> <td valign="top" align="justify"> <p align="justify"><label for="email"><b>Email Address</b> *</label> </td> <td valign="top" align="justify"> <p align="justify"> <input type="text" name="email" maxlength="100" size="40"> </td> <tr> <td valign="top" align="justify"> <p align="justify"><label for="subject"><b>Subject</b> *</label> </td> <td valign="top" align="justify"> <p align="justify"> <input type="text" name="subject" value="WEB SITE ENQUIRY" maxlength="50" size="40"> </td> </tr> <tr> <td valign="top" align="justify"> <p align="justify"><label for="comments"><b>Comments</b> *</label> </td> <td valign="top" align="justify"> <p align="justify"> <textarea name="comments" maxlength="2000" cols="40" rows="6"></textarea> </td> </tr> </table><input class="reset" type="reset" value="Reset All"> Hi guys, i am trying to work with google maps api my issue is with creating an array of markers count the number of marker, and then if it equal two, issue an error msg. i wrote some code, but that doesn't work obviously. and my question is how do i write that code in javascript ? GEvent.addListener(map, 'click', function (overlay, latlng) { if (placeMarker.length < 2) { pendingLatLng = latlng; setTimeout("settleClick()", 225) } else { message("You can only select 2 points."); } }); a sample click event which looks like the line below does work. what am i doing wrong ?: google.maps.event.addListener(map, 'click', function (event) {placeMarker(event.latLng); }) Hi everyone! I want to delete all nodes, but leave one div in my html. var p = document.getElementById('container'); var leave= document.getElementById('leave_this'); while (p.hasChildNodes()) { if(leave != p.childNodes){ p.removeChild(p.firstChild); } } Please help. Cheers Hi guys. Noob at Javascrip and html and this is semi-impossible to me currently. I am working on an assignment where I have 10 image files of 10 different countries. the instruction is to create a page that contains a table with 2 columns in a single row. In the first column, create a list of radio buttons that contains the names of the 10 countries. In the second column, display the flag of the country selected in an ?anchor? element. I am required to use the "onclick" event handler. I have been battling with this for hours, as this book I'm learning from makes assumptions as to the syntax I understand, without explaining it... Would someone please be as kind as to set me on the right path. I have included the sorry piece of code I came up with, that I gathered from other sites and tutorials. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Flags</title> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1"/> </head> <body> <script type="text/javascript"> var cuba = "cuba.jpg"; var argentina="argentina.jpg"; </script> <form name="flagList" action="" method="get"> <p>Click on the country name to view its flag.</p> <p> <input type="radio" name="flag" onclick=document.flagList.flagJpg.value=cuba"/> Cuba<br/> <input type="radio" name="flag" onclick=document.flagList.flagJpg.value=argentina"/> Argentina<br/> </p> <p> <textarea name="flagJpg" cols="75" rows="20" style="background-color: blue; border: none; overflow :hidden; font: 10px tohoma; color:#3F3F3F:></textarea> </P> </form> </body> Hi what i'm trying to do is have it when once a user clicks on a banner the join raffle button will show after clicking on the banner, along with opening up a new window to the link the banner had. I've been trying to set up a onclick event to do this but haven't had success any help would be appreciated. This is the code ive tried using. <div class="moduletable"> <a onclick="{AUP::RAFFLE=4}" href="http://godaddy.com" target="_blank" mce_href="http://godaddy.com"><img src="/images/stories/godaddy%20image.jpg" alt=""></a> </div> Here is the code for the raffle <tr> <td valign="top" colspan="2"> <form action="" method="post" name="RaffleForm"> <input type="hidden" name="aupraffleid" id="aupraffleid" value="4" /> <input type="hidden" name="aupraffleuserid" id="aupraffleuserid" value="63" /> <input type="hidden" name="auprafflepoints" id="auprafflepoints" value="1" /> <input type="hidden" name="auprafflepointsremove" id="auprafflepointsremove" value="1" /> <input class="button" type="submit" name="Submit" value="Sign up for this raffle now!" /> </form> </td> </tr> I have a js file to clean up a textarea when someone copies from a MS Word. I would like to be able to have this remove all the MS Word on submit rather than select a button in an editor. The cleanup.js in located in an includes folder and here is the submit form. How do I include the cleanup.js in this. Any help would be greatly appreciated! Code: <script language='javascript'> function saveChanges(saveDel) { //set the value based on save,delete, or edit document.editDelete.saveDel.value=saveDel; var retVal=true; document.editDelete.saveDel.onsubmit(); document.editDelete.saveDel.value=saveDel; if(saveDel=='delete') { //bring up a confirm if the user clicks delete retVal=confirm("Permanently delete the current record?"); } if(retVal) { //we can active the submit of the form document.editDelete.saveDel.onsubmit(); document.editDelete.submit(); } } </script> Hi, I am brand new to any sort of programming and am taking an HTML class this quarter. We just started javascript and I am working on an assignment where we make a number guessing game. I have been working on this code for a few days and simply cannot figure out what is wrong. It simply doesn't work and at times locks up my browser (Mozilla Firefox). I don't want anyone to write the code for me, I just need a push to begin to understand what I'm doing wrong. Here is what I have so far: <code> <script type="text/javascript"> function guessingGame(){ var secretNumber=Math.floor(Math.random()*100)+1; var numberOfGuesses=0; var guessNumber=parse.Int(document.getElementById('guessNumberValue').value); document.getElementById("guessNumber").value=guessNumber; while (guessNumber!=secretNumber) { if (guessNumber<secretNumber) document.EricaGuess.response.value="Number too low"; if (guessNumber>secretNumber) document.EricaGuess.response.value="Number too high"; if (guessNumber==secretNumber) document.EricaGuess.response.value="You guessed the correct number!";} numberOfGuesses++; document.EricaGuess.numberOfGuessesValue.value=numberOfGuesses; } </script> </head> <body> <form name="EricaGuess"> <div id="Welcome"> <h2> Welcome to Ericas Guessing Game</h2> <p> Enter a number between 1 and 100. See how quickly you can figure out the magic number</p> <input type="button" value="Guess" onclick="guessingGame()"/> <input type="button" value="Reset" onclick="reset"/> <input type="text" id="guessNumber" name="guessNumberValue"/> <input type="text" id="response" name="response" size="75"/> <input type="text" id="numberOfGuessesValue" name="numberOfGuessesValue"/> </code> This is minus the opening and closing tags. Like I said, I am not asking for anyone to code this for me, just some help to understand what the problems are (I'm sure there are many). Thanks for any help you can give. I created a new website for documentation on the product we sell. It can be found at www.predatorgames.info. On the main page is this nice looking jquery photobox. When you click on the smaller pictures it will reload the main one. My problem is how do I make it so that when you click on the large image it will link to another site. Moreover, when they click on the small image it will load a new large image and I would want that to go to a different site if clicked. Dynamic. I was hoping someone could look at the source and tell me where I need to make the change. Please be specific as this is new to me. Thanks ahead of time for the help! heelo people im hoping someone can help me with this for some reason my code isnt working can anyone help me fiind a solution thanks Code: <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title> Activity 14 question 1 </title> </head> <body> <h1>Comparing Height</h1> <p>Click on the button to compare heights</p> <script type="text/javascript"> <!-- function height() { var height; var DispWin; DispWin = window.open("","NewWin", " width=400,height=200"); if(height <178); { DispWin.document.write("Your height is less than or equal to the average"); } else { DispWin.document.write("Your height is more than or equal to the average"); } } --> </script> <form name="calch"> <p>height: <input type="text" size="10" name="compare height" /></p> <p><input type="button" value="Compare Height" onClick="height(document.calch.height.value;" /> </p> </form> </body> </html> thanks |