JavaScript - Noob Question, Javascript Apparently Not Running
Hi all,
I sincerely apologise for the noob question. I have search and searched for an answer but to no avail, so I hope someone on here can help. I'm trying to get a fisheye verticle menu working. I've found somethin which fits the requirement he http://zendold.lojcomm.com.br/ifisheye/ and tried to make it work. It just doesn't. I've tried different versions of mootools etc but I think I'm missing something really stupidky simple. I'd really appreciate it if someone could have a look at my temp page (http://www.parkerbs.com/home1.htm) and point me in the right direction. Many thanks in advance. Paul Similar TutorialsHi all, I'm desperately trying to figure out how to "transform" Javascript commands into HTML code. Excuse my noobness but I really know nothing about Javascript. Basically, I have this Google API Search code: Code: <!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>My Google AJAX Search API Application</title> <script src="http://www.google.com/jsapi?key=CUT"></script> <script language="Javascript" type="text/javascript"> //<![CDATA[ google.load("search", "1"); function OnLoad() { // Create a search control var searchControl = new google.search.SearchControl(); // Add in a full set of searchers var localSearch = new google.search.LocalSearch(); searchControl.addSearcher(localSearch); searchControl.addSearcher(new google.search.WebSearch()); searchControl.addSearcher(new google.search.VideoSearch()); searchControl.addSearcher(new google.search.BlogSearch()); // Set the Local Search center point localSearch.setCenterPoint("New York, NY"); // Tell the searcher to draw itself and tell it where to attach searchControl.draw(document.getElementById("searchcontrol")); // Execute an inital search searchControl.execute("Google"); } google.setOnLoadCallback(OnLoad); //]]> </script> </head> <body> <div id="searchcontrol">Loading...</div> </body> </html> Now, what I'm desperately trying to do since 4-5 hours is to have the search results between the <div id="searchcontrol"></div> encoded as HTML in the loaded page. Currently, when the page is loaded and I look at the source code, I have the word 'Loading...' in the <div> tags, despite in the normal view there are G results listed. I need those results encoded as HTML for SEO reasons. Researching on this matter I thought the problem could be the OnLoad command, that makes the script load after all the other HTML elements are loaded. But I tried to make it load before all the elements in the page, and the problem persists. How can I solve this? Thanks in advance for any help! I'm a total noob who decided to learn som web programming, I hope it's okey to post such questions here. I've written a script to learn how to fill in a value into a textarea by a button click. (See below.) I get it to show the selected number of each button, however the numbers just flashes and disappers right away. I want it to stay in the textarea. How do I do that and why does this problem appear? Head section <script type="text/javascript"> function calculon(i) { document.forms['siffror'].elements['test'].value = i; return; } body section <form name="knappar"> <input name="sifferknapp" type="submit" value=1 onClick=calculon(this.value)> <input name="sifferknapp" type="submit" value=2 onclick=calculon(this.value)> <input name="sifferknapp" type="submit" value=3 onclick=calculon(this.value)><br /> <input name="sifferknapp" type="submit" value=4 onclick=calculon(this.value)> <input name="sifferknapp" type="submit" value=5 onclick=calculon(this.value)> <input name="sifferknapp" type="submit" value=6 onclick=calculon(this.value)><br /> <input name="sifferknapp" type="submit" value=7 onclick=calculon(this.value)> <input name="sifferknapp" type="submit" value=8 onclick=calculon(this.value)> <input name="sifferknapp" type="submit" value=9 onclick=calculon(this.value)><br /> </form> Could someone please change this line so that it respects the global namespace: Code: var selected = students.options[students.selectedIndex].value; The error console is telling me to use document.getElementById but I don't know where to put it. Thanks. I would like to use this code for multiple object on a single page. Code: <SCRIPT LANGUAGE="JavaScript"> function ClipBoard() { holdtext.innerText = copytext.innerText; Copied = holdtext.createTextRange(); Copied.execCommand("Copy"); } </SCRIPT> <SPAN ID="copytext" STYLE="height:150;width:162;background-color:pink"> Text of stuff </SPAN> <TEXTAREA ID="holdtext" STYLE="display:none;"> </TEXTAREA> <BUTTON onClick="ClipBoard();">Copy to Clipboard</BUTTON> The problem is im not sure how to get more than 1 SPAN ID to work with the script. any help would be great! Very new to javascript, so I apologize in advance. I honestly tried to figure this out on my own, and I'm just not able. I'm trying to create a family tree online that has several other related family charts. I want each person's name and birth year to be stored in javascript variables, then I want to be able to just go through the tree, and put the persons name once, and have it put the appropriate name and birthyear in the little boxes that the css is creating. In the js file... I would do this for each family member. Code: var johnname = "John Smith"; var johnbirthyear = "Jan 1 1930"; var janename = "Jane Doe"; var janebirthyear = "Jan 1 1940"; var mikename = "mike wilson"; var mikebirthyear = "Jan 1 1950"; var saraname = "sara johnston"; var sarabirthyear = "Jan 1 1960"; In the HTML file... Code: <div id = "boybox"> <script type="text/javascript"> id = "john"; <!-- this is the only thing I want to have to change --> name = id+"name"; document.write(name); </script> <div id = "year"> <script type="text/javascript"> birthyear = id+"year"; document.write(birthyear); </script> </div> </div> So I thought I had it all figured out. I thought that the above would take the id of John that I added, go to the line that sets the name, add john to the word name, and then document write the variable of johnname from the js file. I know you're laughing at me because of course it instead made the value of name to johnname, then wrote the word johnname in the box. Can anyone point me in the right direction please? ultimately I want to go through and be able to just type the persons name in the html for that box once, and have it update with their appropriate info. Thanks, and sorry for such a rookie question. Every year or two, I want to do something SIMPLE via JS, and each time it's like i've never been there before I simply want a button to show/hide something on click, and I THINK I'm close, but it's not quite working. Here's what I'm toying with. Code: <html> <head> <script type="text/javascript"> function showHide("idName") { if(document.getElementById("idName").style.visibility=="hidden") { document.getElementById("idName").style.visibility=="visible"; } else { document.getElementById("idName").style.visibility=="hidden"; } } </script> </head> <body> <button type="button" onclick="showHide(1)">Click Me!</button> <div id="1" "style=visibility:hidden;"><p>this is the stuff.</p></div> </body> </html> How do I get the button to make that div (in)visible?? ~Mo Hi, I am looking for an efficient way to go thru all the list items I have in an unordered page and change an attribute. I know I should be able to do it using getElementsByTagName, but I can't seem to get it all working. Can someone please point me in the right direction? Thanks, Thad hi all i'm kind of new to the JS world and need your help with some thing i hope it not that big to ask. if you go to linkedin website with your user (www.linkedin.com) you will see a bar called LinkedIn Today. what i need is this kind of bar but with messages changing all the time(moving) is this some thing i need to write from scratch or there some example that i can use? any help will be good for me now because i need to do it ASAP regards,shay Hey guys I'm new to Javascript and need some help with this code Code: <HTML> <HEAD> <TITLE>Swap Test</TITLE> </HEAD> <BODY> <script type="text/javascript"> var numberOne; var numberTwo; // Declaring the values of numberOne and numberTwo var numberOne = 9; var numberTwo = 1; // Variables are swapped numberOne = numberTwo; numberTwo = numberOne; // Output is displayed on-screen document.write (numberOne); document.write (numberTwo); </script> </BODY> </HTML> What I need to do is to declare the two variables, swap their values and then show the results on the screen. ...but it's not working, any ideas? Thanks! x Hi, I have just started to learn Javascript which when loaded into a safari web browser of Firefox browser just simply displays the code. I am currently using a MacBook Leopard operating system I have saved the code (corrected for mistakes, many many times) to my desktop Run my usual browser safari (and tried same with Firefox) loaded the file and all I get is a copy of the code displayed in the browser window. Javascript is enabled for both Please can you suggest some options for me to try and get the code working. All I am doing in this example is copied from a book to turn the background colour of the browser RED Thanks Tom I am trying to run javascript within Iframe and its not running. (The bigger pictu The final target is to do a file upload without refreshing the page, and the original code is using the iframe as the target of the form, and the return from the server is a javascript code that should update some status field on the page. However the code return from the server is not running, so I just paste it in the iframe and it is still not running. ) Code: Content-type: text/html\n\n <html> <script type="text/javascript"> alert("this is running") </script> <iframe id="upload_target" name="upload_target" src="#" style="width:100;height:100;border:0px solid #fff;"> <script type="text/javascript"> alert("this not running") </script> </iframe> </html> Hello I am setting up a Javascript function in a page called functions.php function onAddBookmarkPressed() { <? mail("XXXXXXX", "Mail","Bookmark"); ?> } And calling it from another place within the page <div class="barstepimg"><img src="http://staggan.com/my_dir/images/progress_bar/fb_buttons/add_bookmark.gif" onclick="onAddBookmarkPressed();"/></div> I include functions.php in my index.php page... When I run the index.php page the function above runs and emails me... Any idea why? Hello Firstly, this is the full pastebin code of my admin page because i failed adding full code here correctly: http://pastebin.com/tQAaQjYC and the screenshot of the slide manager page: http://img36.imageshack.us/img36/4830/slidemanager.jpg Well, I have a Slide Manager as an admin menu page in Wordpress. When i click "Add new slide" button, as you see in the screenshot above, it adds a new "slide field" in which that dropdown list shows all titles of posts. (Ignore other parts as they work as expected) What i would like to do is, when i choose a post title, the text box which is next to dropdown to be populated automatically by the post's url adress. I want it to be worked for every "slide field" added via "Add new slide" button. I actually made it work that way outside the foreach: PHP Code: <script language="JavaScript"><!-- function onChange() { var Current = document.myform.link.selectedIndex; document.myform.currentText3.value = document.myform.link.options[Current].value; } //--> </script> <select name="link" onChange="onChange(this.value);"> <?php if($_POST['action'] == save ) { $selected = "selected"; } else{ $selected = ""; } echo '<option value="">...... Choose One ...... </option>'; $args = array( 'post_type' => 'post', 'nopaging' => true ); $the_query = new WP_Query( $args ); while ( $the_query->have_posts() ) : $the_query->the_post(); echo '<option '.$selected.' value="'.get_permalink( $post->ID ).'">'; the_title(); echo '</option>'; endwhile; ?> </select> <input name="currentText3" type="text" value=""> But when i add this after the opening code of foreach, i.e: PHP Code: <?php foreach($nivoslides as $k => $slide) : ?> Each slide field shows the dropdown and text box properly as you see in screenshot BUT none of them work. I tried to add brackets but it didn't work either: Code: <select name="link[]" onChange="onChange(this.value);"> I guess it's the javascript code that should be edited or entirely changed but i have no idea how to do it. I would be grateful for any help. Thanks in advance. I have a slideshow that goes through pictures once you click on the Play button and doesn't stop until you press on the Stop button. How can I make it so that it automatically plays once the website loads without having to click on the Play button? Heres the code: Code: <div class="tabs png"><span class="tabs-inner"><a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a> <a href=""></a></span></div> <div class="slider-indent-button"> <a href="#" onClick='$("div.tabs").tabs().play();'>Play</a> <a href="#" onClick='$("div.tabs").tabs().stop();'>Stop</a> </div> All help is much appreciated!!! I'm quite new to JavaScript, but I wanted to add a feature to a sample website that I need to have done by tomorrow night. I have two HTML paragraphs which I will call "a" and "b". Below those paragraphs I have a text box and a submit button. This is how I declared them in the HTML doc: Code: <input type="text" name="message" value="Blank Message" id="newsmessage" /> Code: <input type="button" value="Post" id="submitbutton" onclick="updatepost()" /> Now when I click the submit button I want paragraph b to replace itself with paragraph a, and I want paragraph a to replace itself with the text in the text box. Here's the JavaScript that I have written. (I'm aware it's probably quite off.) Note: paragraph a is toppost, paragraph b is bottompost, the text box is named message, and I created p1 and p2 as temporary holders for the strings. Err... variables. Code: <script type="text/javascript"> function updatepost() { p2=document.getElementById("toppost"); document.getElementById("bottompost").innerHTML=p2; p1=document.message.elements[i]; document.getElementById("toppost").innerHTML=p1; } </script> As of right now the paragraph a holds the text "a" and paragraph b holds the text "b". When I click post paragraph a still reads "a" and paragraph b reads "[object HTMLParagraphElement]". Sorry for my minimal JavaScript knowledge; I have full intentions of fully learning the language quite soon. I just wanted to implement this feature in a site that I had to create and my deadline is tomorrow. Thanks guys! -Dave I am working on a site for an online radio station and I want an external player to launch on site visit and to continue playing as the visitors surf my site. I feel I am 95% there as I have the player spawning on launch and checking for popup blockers. If a popup blocker is found the user is prompted to add my domain to their allowed lists so that future visits will launch the player right out of the box. My problem is this. When someone navigates back to the "home" page (where the script is located the external player window reloads and I do not want it to. I have found a couple of sites that say do this and that but I am a 100% novice at javascript and can not figure it out. here is the url of the site I am building http://www.radiotrips.com/czmradio - If you have popup blocker on you should get an alert. If not a small player should launch here is the code that I am using to spawn the external player and check for popup blockers ************** <script language="javascript" type="text/javascript"> function detectPopupBlocker() { var czmTest = window.open("http://www.radiotrips.com/czmradio/player/mini/no_ads.html","Cozumel Radio","width=478,height=260"); if (!czmTest) { alert("We were unable to automatically open the Cozumel Radio Player due to your pop-up blocker... Please add CozumelRadio.net to your allowed sites for your best listening experience"); } else { window.open("http://www.radiotrips.com/czmradio/player/mini/no_ads.html","Cozumel Radio","width=478,height=260"); } } ************** if anyone could add the code that would make the browser check to see if this window is already open and if so not reload it I would GREATLY appreciate it. I feel like it is 1 to 2 lines of code max according to what I have seen elsewhere but just cant figure it out. Thanks a Million in advance Chris Hey, I've got to make the values of some textboxes change the co-ordinates of my sprite on a canvas and havent a clue on how to do it, Here is my form with the two textboxes and submit button: <form> x: <input type="text" name="x" /><br /> y: <input type="text" name:"y" /><br /> <input type="submit" value="Submit"/><br /> </form> And i need it so that they change the values of these: //this shows where my sprite will start on the canvas var block_x; var block_y; searched the internet for hours and cant really find anything i understand or works. any help is much appreciated I was debugging my code looking for a loop. So in the process I added a confirm request and if the user clicked cancel I coded location.replace("Kill.html"). Problem was that the JAVASCRIPT continued to run until either it finished or I used the Task Manager to end the session. There3 was a small difference in browsers: Firefox put up the new screen while continuing to run the JAVASCRIPT while IE didn't put up the new screen until after the JAVASCRIPT was finished. I could tell the JAVASCRIPT was still running because the confirm messages kept popping up.
I'm working on a website. Basic layout is up at http://adamnerland.com/onestudent/ The layout looks perfect and the image slider I'm using works in every browser I've tested except for IE 7.0 and earlier. I'm not a JavaScript programmer, so I'm not really sure how to debug this. Is it due to conflicts with my dropdown menu JavaScript? Anyone have any ideas? Hi all, thank you in advance for reading this thread. I have a very simple web page that is comprised of the same image over and over again. I have it to when you click on it, it swaps the image out and adds 1 to the counter. I need it to subtract 1 when you click it again. I am having the most difficult time trying to solve this one, so hopefully someone can help. Here are the scripts I am working with: <script type="text/javascript"> var namesVec = new Array("block.png", "block_hover.png"); var root='images/'; function swapImg(ima){ // divides the path nr = ima.getAttribute('src').split('/'); // gets the last part of path, ie name nr = nr[nr.length-1] // former was .split('.')[0]; if(nr==namesVec[0]){ima.setAttribute('src',root+namesVec[1]);} else{ima.setAttribute('src',root+namesVec[0]);} } function addItem(thecount){ if (document.images) { document.getElementById(thecount).innerHTML = parseFloat(document.getElementById(thecount).innerHTML)+1; } } </script> I mean, is there a way to assign "add 1 when clicked" or "subtract 1 when clicked" to image properties? Or may this needs a complete rewrite? Any direction and advise would be appreciated. Sincerely, Jaime |