JavaScript - Adding Php Code To Page Using Js
Basically, I have it so that when you click something, then it expands and then shows text. The part I am having trouble at is the text being a php include. Here is the line that works for pre-typed in information:
Code: divbody.innerHTML = "Some random text here."; Then when I want to do something like this: Code: divbody.innerHTML = "<?php include('widgets/products.php'); ?>"; Then the actual innerHTML comes out like this: Code: <!--?php include('widgets/products.php'); ?--> It seems as if it is changing '<' and '>' to '<!--' and '-->' respectively. Similar TutorialsHi I was wondering if it is possible to add js logging onto a webpage and have this writing out to a separate file with the details? I have a page which is only showing the header and not the rest of the page, I want to add loggin code to find out where it is breaking. Is this possible and how would I go about setting it up? Code: <script type="text/javascript" language="javascript"> function toggle() { var ele = document.getElementById("toggle"); var text = document.getElementById("display"); if(ele.style.display == "block") { ele.style.display = "none"; text.innerHTML = "Show"; } else { ele.style.display = "block"; text.innerHTML = "Hide"; } } </script> Code: <a href="javascript:toggle();" id="display" style="color:#000000">Show</a> <div id="toggle" style="display:none">CONTENT</div> The above toggle code works perfectly. How can I edit the code to use buttons instead of text? In other words: How can I replace two different texts that say "Show" and "Hide" with two different buttons that say "Show" and "Hide"? Thanks. I have a function to accept number and certain text only when "Enter" key is pressed. Code: function handleEnter(field, event){ var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; var tmp_val = ""; if (keyCode == 13) { if(field.name=="number" && field.value.replace(/ /g,"").length>1){ field.value = field.value.replace(/ /g,""); field.value = field.value.toUpperCase(); tmp_val = field.value; if (isNaN(tmp_val) && tmp_val!="ABC") { field.value = ""; field.focus(); return false; } else { some codings here } } } } However, when I added a second condition, the code stops working Code: if (isNaN(tmp_val) && (tmp_val!="ABC" ||tmp_val!="DEF") ) Anyone pls help~ Tks~ Hi i have two images which are part of a rollover button that i want to have paused until the intro animation finishes. I have the javascript code but the rollover images are specified in the css. I just have the id to them in the html. I was wondering if anyone knew how to include the rollover files with the pausing javascript code. the files are profile.gif and profileover.gif. I tried to add the files to the preload part of the javascript but that didn't work. The website is www.creationindex.com/indextest.html thank you
Hi. I need help in adding a parenthesis in the area code of the phone number and validating it also. I made some javascript code but it is not working. Can somebody please help? I just need the code in adding () in the area code. For example: When user enter 10 digit number no spaces or dashes such as 0000000000 or 000-000-0000, I would like to have this format right away (000)000-0000. I know how to replace the characters but adding it is a tricky one for me. Can somebody please help? Thanks. Hello all, I am not really a javascript programmer... more of a copy/paste and tweak kind of guy. Hopefully you can help me out with this anyway. I am using the following script to play a sound when an object is clicked. (In header) Code: <script language="javascript" type="text/javascript"> function playSound(soundfile) { document.getElementById("dummy").innerHTML= "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />"; } </script> (Hyperlink to play sound) Code: <a href="#" onclick="playSound('URL to soundfile');"> I would like the hyperlink to also load a webpage after a 10 second delay (the duration of the sound effect). Is that something that is possible and can someone please point me in the right direction? Thank you I want to insert this star trail effect script to page below but star trail doesn't appear on most areas and script corrupts several objects' position. How can I insert it successfully? http://www.orkinosfilm.com/melissa/index.html Code: <head> <style type="text/css"> body {overflow: scroll; overflow-x: hidden;} .anyClass { position: relative; visibility: hidden; left: -5000px; } </style> </head> <body bgcolor="#000000"> <p><!--webbot bot="HTMLMarkup" startspan --><script language="JavaScript1.2"> <!-- /* Submitted by Marcin Wojtowicz [one_spook@hotmail.com] Featured on JavaScript Kit (http://javascriptkit.com) Modified by JK to be IE7+/ Firefox compatible For this and over 400+ free scripts, visit http://javascriptkit.com */ var trailLength = 10 // The length of trail (8 by default; put more for longer "tail") var path = "cursor_star.png" // URL of your image var standardbody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body //create reference to common "body" across doctypes var i,d = 0 function initTrail() { // prepares the script images = new Array() // prepare the image array for (i = 0; i < parseInt(trailLength); i++) { images[i] = new Image() images[i].src = path } storage = new Array() // prepare the storage for the coordinates for (i = 0; i < images.length*3; i++) { storage[i] = 0 } for (i = 0; i < images.length; i++) { // make divs for IE and layers for Navigator document.write('<div id="obj' + i + '" style="position: absolute; z-Index: 100; height: 0; width: 0"><img src="' + images[i].src + '" width='+(16-i)+' height='+(16-i)+'></div>') } trail() } function trail() { // trailing function for (i = 0; i < images.length; i++) { // for every div/layer document.getElementById("obj" + i).style.top = storage[d]+'px' // the Y-coordinate document.getElementById("obj" + i).style.left = + storage[d+1]+'px' // the X-coordinate d = d+2 } for (i = storage.length; i >= 2; i--) { // save the coordinate for the div/layer that's behind storage[i] = storage[i-2] } d = 0 // reset for future use var timer = setTimeout("trail()",10) // call recursively } function processEvent(e) { // catches and processes the mousemove event if (window.event) { // for IE storage[0] = window.event.y+standardbody.scrollTop+10 storage[1] = window.event.x+standardbody.scrollLeft+10 } else { storage[0] = e.pageY+12 storage[1] = e.pageX+12 } } initTrail() document.onmousemove = processEvent // start capturing //--> </script><!--webbot bot="HTMLMarkup" endspan --></p> </body> I have the following javascript function: [ function addNewWindowEvent(evType, fn) { if (window.addEventListener) { this.addEventListener("load", fn, false); return true; } else if (window.attachEvent) { var onload = "onload" this.attachEvent(onload, fn); return true; } else { return false; } } ] which is giving me a an exception every time a page on our site loads. The actual exception in firefox is this: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: https://cms-dev.stchas.edu/global/js/hdvscripts.js :: addNewWindowEvent :: line 5" data: no] and I'm not sure exactly what it's complaining about. I'm relatively new to javascript so diagnosing and fixing this problem has me quite puzzled, and so far I have been unable to find anything helpful when I try and google for information on this. I would appreciate any help or suggestions. Thanks. henryv Ok guys if you look at this page www.runningprofiles.com/members/shout/view.php my code works great.... But when i add it to the rest of the script the code wont work shows he http://www.runningprofiles.com/membe...ll_Script.php# Below is view.php (the one that works) and the one added to the code scirpt is the one the does not. PHP Code: <script type="text/javascript" src="http://ajax.googleapis.com/ajax/ libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript"> $(function() { $(".view_comments").click(function() { var ID = $(this).attr("id"); $.ajax({ type: "POST", url: "viewajax.php", data: "msg_id="+ ID, cache: false, success: function(html){ $("#view_comments"+ID).prepend(html); $("#view"+ID).remove(); $("#two_comments"+ID).remove(); } }); return false; }); }); </script> <ol> <?php //Here $id is main message msg_id value. $csql=mysql_query("select * from comments where msg_id_fk='130' order by com_id "); $comment_count=mysql_num_rows($csql); if($comment_count>2) { $second_count=$comment_count-2; ?> <div class="comment_ui" id="view130"> <a href="#" class="view_comments" id="130">View all <?php echo $comment_count; ?> comments</a> </div> <?php } else { $second_count=0; } ?> <div id="view_comments130"></div> <div id="two_comments130"> <table width="30%"> <?php $small=mysql_query("select * from comments where msg_id_fk='130' order by com_id limit $second_count,2 "); while($rowsmall=mysql_fetch_array($small)) { $c_id=$rowsmall['com_id']; $comment=$rowsmall['comment']; ?> <div class="comment_actual_text"> <tr> <td style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid" valign="top"> <table style="WIDTH: 100%; BORDER-COLLAPSE: collapse" align="left"> <tr> <td width="5%" style="VERTICAL-ALIGN: middle; TEXT-ALIGN: center"><img style="WIDTH: 30px; HEIGHT: 30px" alt="srinivas" src="http://www.gravatar.com/avatar.php?gravatar_id=7a9e87053519e0e7a21bb69d1deb6dfe" border="1" /></td> <td style="VERTICAL-ALIGN: top; TEXT-ALIGN: left"> <strong>Jarratt</strong> <?php echo $comment; ?> <br /><span style="COLOR: #a9a9a9">10 min ago - ID = <?php echo $c_id;?> </span></td> </tr> </table><br /> </td> </tr> </div> <?php } ?> </table> </div> </ol> Facebook_Wall_Script.php PHP 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>9lessons Applicatio Demo</title> <link href="frame.css" rel="stylesheet" type="text/css"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script> <script type="text/javascript" src="jquery.oembed.js"></script> <script type="text/javascript"> <script type="text/javascript"> $(function() { $(".view_comments").click(function() { var ID = $(this).attr("id"); $.ajax({ type: "POST", url: "../viewajax.php", data: "msg_id="+ ID, cache: false, success: function(html){ $("#view_comments"+ID).prepend(html); $("#view"+ID).remove(); $("#two_comments"+ID).remove(); } }); return false; }); }); $(function() { $(".comment_button").click(function() { var element = $(this); var boxval = $("#content").val(); var dataString = 'content='+ boxval; if(boxval=='') { alert("Please Enter Some Text"); } else { $("#flash").show(); $("#flash").fadeIn(400).html('<img src="ajax.gif" align="absmiddle"> <span class="loading">Loading Update...</span>'); $.ajax({ type: "POST", url: "update_ajax.php", data: dataString, cache: false, success: function(html){ $("ol#update").prepend(html); $("ol#update li:first").slideDown("slow"); document.getElementById('content').value=''; $('#content').value=''; $('#content').focus(); $("#flash").hide(); $("#expand_url").oembed(boxval); } }); } return false; }); / Delete Wall Update $('.delete_update').live("click",function() { var ID = $(this).attr("id"); var dataString = 'msg_id='+ ID; var parent=$("#bar"+ID); jConfirm('Are you sure you want to delete this message?', 'Confirmation Dialog', function(r) { if(r==true) { $.ajax({ type: "POST", url: "delete_update.php", data: dataString, cache: false, success: function(html){ parent.slideUp(300,function() { parent.remove(); }); } }); } }); return false; });//comment slide $('.comment').live("click",function() { var ID = $(this).attr("id"); $(".fullbox"+ID).show(); $("#c"+ID).slideToggle(300); return false; }); //commment Submint $('.comment_submit').live("click",function() { var ID = $(this).attr("id"); var comment_content = $("#textarea"+ID).val(); var dataString = 'comment_content='+ comment_content + '&msg_id=' + ID; if(comment_content=='') { alert("Please Enter Comment Text"); } else { $.ajax({ type: "POST", url: "comment_ajax.php", data: dataString, cache: false, success: function(html){ $("#commentload"+ID).append(html); document.getElementById("textarea"+ID).value=''; $("#textarea"+ID).focus(); } }); } return false; }); // Delete Wall Update $('.delete_update').live("click",function() { var ID = $(this).attr("id"); var dataString = 'msg_id='+ ID; var parent=$("#bar"+ID); jConfirm('Are you sure you want to delete this message?', 'Confirmation Dialog', function(r) { if(r==true) { $.ajax({ type: "POST", url: "delete_comment.php", data: dataString, cache: false, success: function(html){ $("#comment"+ID).slideUp(); } }); } return false; }); return false; }); </script> <style type="text/css"> body { font-family:Arial, Helvetica, sans-serif; font-size:12px; } .update_box { background-color:#D3E7F5; border-bottom:#ffffff solid 1px; padding-top:3px } a { text-decoration:none; color:#d02b55; } a:hover { text-decoration:underline; color:#d02b55; } *{margin:0;padding:0;} ol.timeline {list-style:none;font-size:1.2em;}ol.timeline li{ display:none;position:relative; }ol.timeline li:first-child{border-top:1px dashed #006699;} .delete_button { float:right; margin-right:10px; width:20px; height:20px } .cdelete_button { float:right; margin-right:10px; width:20px; height:20px } .feed_link { font-style:inherit; font-family:Georgia; font-size:13px;padding:10px; float:left; width:350px } .comment { color:#0000CC; text-decoration:underline } .delete_update { font-weight:bold; } .cdelete_update { font-weight:bold; } .post_box { height:55px;border-bottom:1px dashed #006699;background-color:#F3F3F3; width:499px;padding:.7em 0 .6em 0;line-height:1.1em; } #fullbox { margin-top:6px;margin-bottom:6px; display:none; } .comment_box { display:none;margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px; height:50px; } .comment_load { margin-left:90px; padding:10px; background-color:#d3e7f5; width:300px; height:30px; font-size:12px; border-bottom:solid 1px #FFFFFF; } .text_area { width:290px; font-size:12px; height:30px; } #expand_box { margin-left:90px; margin-top:5px; margin-bottom:5px; } embed { width:200px; height:150px; } </style> </head> <body> <?php include '../../../settings.php'; ?> <div align="center"> <table cellpadding="0" cellspacing="0" width="500px"> <tr> <td> <div align="left"> <form method="post" name="form" action=""> <table cellpadding="0" cellspacing="0" width="500px"> <tr><td align="left"><div align="left"> <h3>What are you doing?</h3></div></td></tr> <tr> <td style="padding:4px; padding-left:10px;" class="update_box"> <textarea cols="30" rows="2" style="width:480px;font-size:14px; font-weight:bold" name="content" id="content" maxlength="145" ></textarea><br /> <input type="submit" value="Update" id="v" name="submit" class="comment_button"/> </td> </tr> </table> </form> </div> <div style="height:7px"></div> <div id="flash" align="left" ></div> <ol id="update" class="timeline"> </ol> <div id='old_updates'> <?php $small=mysql_query("select * from messages2 order by msg_id desc LIMIT 5"); while($r=mysql_fetch_array($small)) { $id=$r['msg_id']; $msg=$r['message']; ?> <div align="left" class="post_box"> <span style="padding:10px"><?php echo $msg.'....'.$id; ?> </span> </div> <ol> <?php //Here $id is main message msg_id value. $csql=mysql_query("select * from comments where msg_id_fk='$id' order by com_id "); $array = mysql_fetch_assoc($csql); $comment_count=mysql_num_rows($csql); if($comment_count>2) { $second_count=$comment_count-2; ?> <div class="comment_ui" id="view<?php echo $id; ?>"> <a href="#" class="view_comments" id="<?php echo $id; ?>">View all <?php echo $comment_count; ?> comments</a> </div> <?php } ?> <div id="view_comments<?php echo $id; ?>"></div> <div id="two_comments<?php echo $id; ?>"> <table width="50%"> <?php $small2=mysql_query("select * from comments where msg_id_fk='$id' order by com_id limit 2 "); while($rowsmall22=mysql_fetch_array($small2)) { $c_id=$rowsmall22['com_id']; $comments=$rowsmall22['comment']; ?> <div class="comment_actual_text"> <tr> <td style="BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid" valign="top"> <table style="WIDTH: 100%; BORDER-COLLAPSE: collapse" align="left"> <tr> <td width="5%" style="VERTICAL-ALIGN: middle; TEXT-ALIGN: center"><img style="WIDTH: 30px; HEIGHT: 30px" alt="srinivas" src="http://www.gravatar.com/avatar.php?gravatar_id=7a9e87053519e0e7a21bb69d1deb6dfe" border="1" /></td> <td style="VERTICAL-ALIGN: top; TEXT-ALIGN: left"> <strong>Jarratt</strong> <?php echo $comments; ?> <br /><span style="COLOR: #a9a9a9">10 min ago - ID = <?php echo $c_id.'...'.$id;?> </span></td> </tr> </table><br /> </td> </tr> </div> <?php } ?> </table> </div> </ol> <?php } ?> </div> </td> </tr> </table> </div> </body> </html> Hi Everyone, I'm using the code below to rotate between some testimonials for my website and I realized that it would be better to make the order random rather than always cycling the same each time to be sure the later ones get equal visibility on the home page. I found the code and tweaked it as I needed but I'm not familiar enough with java to know how to add a randomizing component. I'd appreciate any help offered since I hope it's straight forward enough for someone who knows the language well. Thanks a lot! [CODE] var quote=new Array(); quote[0]="An essential tool in preparation for any show. Valuable time is saved, refining vocals much earlier in the process."; quote[1]="Invaluable for learning vocal lines! A brilliantly simple and easy to use interface that saved me hours of time."; quote[2]="MixMyPart saved us almost a week of rehersal time. A brilliant invention. Singers come in less nervous and more focused."; <!-- quote[3]="An invaluble tool for learning vocal lines! Brilliantly simple and easy to use interface that saved me hours of time."; --> var quoteperson=new Array(); quoteperson[0]="Bob Foster, <font color=\"ffffff\">Music Director</font>"; quoteperson[1]="Liam Tobin, <font color=\"ffffff\">Actor</font>"; quoteperson[2]="Shawn Wright, <font color=\"ffffff\">Actor</font>"; <!-- quoteperson[3]="Liam Tobin, <a href=\"website.html\" target=\"_blank\">website.org</a>"; --> var speed=9000; var q=0; function showQuote() { document.getElementById("tst").innerHTML="“" +quote[q]+"”"; document.getElementById("tstperson").innerHTML=quo teperson[q]; q++; if(q==quote.length) { q=0; } } setInterval('showQuote()',speed); Hi, The following code adds an element to a page when a new address is inputted. Is there a way to remove all added elements with a Clear All button? I have a "Clear All" button with id="ClearAddresses" but I don't know how to remove all created elements - the code here only removes one at a time, since the element is created when the "Search" button is clicked. Code: var Dom = { get: function(el) { if (typeof el === 'string') return document.getElementById(el); else return el; }, add: function(el, dest) { var el = this.get(el); var dest = this.get(dest); dest.appendChild(el); }, remove: function(el) { var el = this.get(el); el.parentNode.removeChild(el); } }; var Event = { add: function() { if (window.addEventListener) { return function(el, type, fn) { Dom.get(el).addEventListener(type, fn, false); }; } else if (window.attachEvent) { return function(el, type, fn) { var f = function() { fn.call(Dom.get(el), window.event); }; Dom.get(el).attachEvent('on' + type, f); }; } }() }; Event.add(window, 'load', function(){ var i = 0; Event.add('addressSearch', 'click', function() { //This is a hack way of doing things...thanks asyncronous callbacks... /sarcasm add_visited_address(); }); }); var visited_address_array = Array(); var address_check=0; var MAX_ADDRESS_CHECKS=50; function in_visited_address_array(new_entry) { for(var i=0; i<visited_address_array.length; i++) { if(new_entry == visited_address_array[i]) return true; } //otherwise... return false; } function add_visited_address() { if(addressSearchAddress !=null) { var el = document.createElement('span'); var el_remove = document.createElement('span'); var new_entry = addressSearchAddress + ' : [' + addressSearchRadius + ']'; var new_address = addressSearchAddress; var new_radius = addressSearchRadius; el.innerHTML = '<span class=\"address-text\">' + new_entry + '</span><br>'; el_remove.innerHTML = "<a onMouseOver=\"rollover('address_remove')\" onMouseOut=\"rollout('address_remove')\" style='cursor:pointer;'>" + "<img src=\"images/tabs-icons/normal-address_remove.png\" name='address_remove' title='remove' alt='remove'></a> "; if(!in_visited_address_array(new_entry)) { visited_address_array.push(new_entry); Dom.add(el_remove, 'AddressesVisited'); Dom.add(el, 'AddressesVisited'); Event.add(el, 'click', function(e) { document.getElementById('address').value = new_address; document.getElementById('radius').value = new_radius; ClickGeocode(); }); Event.add(el_remove, 'click', function(e) { Dom.remove(el); Dom.remove(this); }); address_check=0; } else if(visited_address_array[visited_address_array.length-1] == new_entry && address_check<MAX_ADDRESS_CHECKS) { setTimeout("add_visited_address();", 100); address_check++; } } else setTimeout("add_visited_address();", 50); } Hi, I'm not sure where I have translated this incorrectly. I have one google map embedded on my page which works fine. But I wanted to add a second one. I thought the easiest way to do this would be to have a second page which is called later on with all the details on it for the second map. However although I think (this I presume is where I went wrong) I have replicated the instructions correctly the place holder for the second map just remains blank. This is the code for my called page with the instructions for the second map: PHP Code: <?php echo $_POST['Map'] . '<br />'; ?> <div id="placemap_canvas"></div> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html {height:250px} body {height:250px} #placemap_canvas {width:100%; height:150px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" /> </script> <script type="text/javascript"> var latlng = new google.maps.LatLng ( <?php include("dbconnect.php"); $result = mysql_query("SELECT * FROM regions WHERE RegionPId='{$_POST['Map']}'"); while($row = mysql_fetch_array($result)){ echo $row['maplink']; } mysql_close($con); ?> ); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("placemap_canvas"), myOptions); } </script> And this is the script of the main page, just in case I would be better off keeping them both in one place. Code: <head> <script type="text/javascript"> function loadSubPlace(File,ID,Msg,Eile,EID,Esg){ loadXMLDoc1(File,ID,Msg); var mimer = setTimeout(function(){loadXMLDoc1(Eile,EID,Esg)},5000); } </script> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html {height:250px} body {height:250px} #map_canvas {width:30%; height:250px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" /> </script> <script type="text/javascript"> function initialize() { var latlng = new google.maps.LatLng ( <?php include("dbconnect.php"); $result = mysql_query("SELECT * FROM countries WHERE Country='{$_SESSION['Country']}'"); while($row = mysql_fetch_array($result)){ echo $row['Map']; } mysql_close($con); ?>); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } </script> </head> <body onload="initialize()"> <div class="countryright" id="map_canvas"> include("dbconnect.php"); $snowball=explode(';',$_POST['syringa']); $turnsol=$snowball[1]; $violet =$snowball[2]; $wakerobin=$snowball[3]; global $turnsol; global $violet; global $wakerobin; echo '<center><b><big>' . $wakerobin. '</big></b></center><br /><br />'; $result=mysql_query("SELECT * FROM regions WHERE country='{$turnsol}' AND region='{$violet}' AND place='{$wakerobin}' AND sub !='' ORDER BY sub ASC"); while($row = mysql_fetch_array($result)){ $wheat="{$row['RegionPId']};{$turnsol};{$violet};{$wakerobin};{$row['sub']}"; $tigerlilly=$row['RegionPId']; echo '<input type="button" class="button3" name="place" id="place" value="' . $row['sub'] . '" onclick="loadSubPlace(\'getPlace.php\',\'txtHintPlaceSub\',\'hepatica=' . urlencode($wheat) . '\',\'getPlaceMap.php\',\'placemapcanvas\',\'Map=' . urlencode($tigerlilly) . '\');" />'; } echo '<input type="button" class="button3" name="addplace" id="addplace" value="Add Place" onclick="loadXMLDoc1(\'getAddPlaceSub.php\',\'txtHintPlaceSub\', encodeURI(\'addsubplace=' . $_POST['syringa'] . '\'));" />'; echo '<br /><br /><div id="txtHintPlaceSub"></div><br /><br />'; mysql_close($con); ?> I've cut out the script that doesn't relate to this so I hope I haven't missed anything important. I am trying to get 2 versions of the code below to run simultaneously on the same page (in different div tags), but with different pictures and timer. I can get both to work seperately so I know the code works, but when I put both on the same page only one works. Can anyone solve this problem? Code: <script type="text/javascript"> var ultimateshow=new Array() //ultimateshow[x]=["path to image", "OPTIONAL link for image", "OPTIONAL link target"] ultimateshow[0]=['image1.png', '', ''] ultimateshow[1]=['image2.png', '', ''] ultimateshow[2]=['image3.png', '', ''] //configure the below 3 variables to set the dimension/background color of the slideshow var slidewidth="190px" //set to width of LARGEST image in your slideshow var slideheight="350px" //set to height of LARGEST iamge in your slideshow var slidecycles="5" //number of cycles before slideshow stops (ie: "2" or "continous") var randomorder="yes" //randomize the order in which images are displayed? "yes" or "no" var preloadimages="yes" //preload images? "yes" or "no" var slidebgcolor='white' //configure the below variable to determine the delay between image rotations (in miliseconds) var slidedelay=3000 ////Do not edit pass this line//////////////// var ie=document.all var dom=document.getElementById var curcycle=0 if (preloadimages=="yes"){ for (i=0;i<ultimateshow.length;i++){ var cacheimage=new Image() cacheimage.src=ultimateshow[i][0] } } var currentslide=0 function randomize(targetarray){ ultimateshowCopy=new Array() var the_one var z=0 while (z<targetarray.length){ the_one=Math.floor(Math.random()*targetarray.length) if (targetarray[the_one]!="_selected!"){ ultimateshowCopy[z]=targetarray[the_one] targetarray[the_one]="_selected!" z++ } } } if (randomorder=="yes") randomize(ultimateshow) else ultimateshowCopy=ultimateshow function rotateimages(){ curcycle=(currentslide==0)? curcycle+1 : curcycle ultcontainer='<center>' if (ultimateshowCopy[currentslide][1]!="") ultcontainer+='<a href="'+ultimateshowCopy[currentslide][1]+'" rel="nofollow" target="'+ultimateshowCopy[currentslide][2]+'">' ultcontainer+='<img src="'+ultimateshowCopy[currentslide][0]+'" border="0">' if (ultimateshowCopy[currentslide][1]!="") ultcontainer+='</a>' ultcontainer+='</center>' if (ie||dom) crossrotateobj.innerHTML=ultcontainer if (currentslide==ultimateshow.length-1) currentslide=0 else currentslide++ if (curcycle==parseInt(slidecycles) && currentslide==0) return setTimeout("rotateimages()",slidedelay) } if (ie||dom) document.write('<div id="slidedom" style="width:'+slidewidth+';height:'+slideheight+'; background-color:'+slidebgcolor+'"></div>') function start_slider(){ crossrotateobj=dom? document.getElementById("slidedom") : document.all.slidedom rotateimages() } if (ie||dom) window.onload=start_slider </script> i have a javascript bookmark to log me onto my schools site javascript: window.location.href="http://www.MySchool";login=document.getElementById('Login'); void(login.value='user'); pass=document.getElementById('pass');void(pass.value='pass'); LoginbuttonSubmit(); without window.location.href="http://www.MySchool" it works fine if the page is already open, but with using the link to open the page, it runs the remaning script before the page loads and it doesn't work. is there any way to fix this withou using setTimeout() I am using the page peel code below on my social network site. I would like to modify it so that it only appears on the main page of my site. What do I need to change/add? Thanks! Code: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> $(document).ready(function(){ //Page Flip on hover $("#pageflip").hover(function() { $("#pageflip img , .msg_block").stop() .animate({ width: '506px', height: '517px' }, 500); } , function() { $("#pageflip img").stop() .animate({ width: '70px', height: '72px' }, 220); $(".msg_block").stop() .animate({ width: '70px', height: '70px' }, 200); }); }); </script> <div id="pageflip"> <a href="http://pagepeeler.ning.com/page/page/list"><img src="http://i187.photobucket.com/albums/x172/billvasko/pagepeel.png" alt="" /> <span class="msg_block">Page Peeler</span> </a> </div> CSS: . #pageflip { position: relative; } #pageflip img { width: 70px; height: 72px; z-index: 99; position: absolute; right: 0; top: 0; -ms-interpolation-mode: bicubic; } #pageflip .msg_block { width: 70px; height: 70px; position: absolute; z-index: 50; right: 0; top: 0; background: url(http://img18.imageshack.us/img18/2572/pagepeel.jpg) no-repeat right top; text-indent: -9999px; Hey guys, On my personal website, I just created a rollover image gallery using Javascript. Each time you roll over a thumbnail, the image above changes to the corresponding thumbnail image. http://www.thelittlelizzard.com/Bahamas.html After spending hours getting that to work properly, my footer is now showing as one huge blue link. I believe I'm forgetting to close a tag somewhere? Being new to Javascript, I don't have a clue what I am forgetting to close to cause my footer to become a huge blue link like that. Does anyone have any ideas? Here is a copy of the code of my body section where I believe the problem may be... Code: <p>Where we stayed: <a href="http://www.starwoodhotels.com/sheraton/property/overview/index.html?propertyID=3067" onclick="window.open(this.href);return false;">Radisson Cable Beach Resort</a> (Now called Sheraton Nassau Cable Beach): </p> <p>Dates we travelled: March 2004, 2005 and 2006</p> <p>Flight Time from New York: 2.5 hours</p> <br /><br /> <div id="divcenter"> <p><img align="center" border="0" src="Bahamas/bahamas.jpg" style="border-right: 1 solid #006666" name="altimg" width="548" height="316" /> </p> <p> <a onmouseover="on('image1');" onmouseout="off('image1')"> <img src="Bahamas/bahamas.jpg" width="45" height="45"></a> <a onmouseover="on('image2');" onmouseout="off('image2')"> <img src="Bahamas/bahamas-1.jpg" width="45" height="45"></a> <a onmouseover="on('image3');" onmouseout="off('image3')"> <img src="Bahamas/bahamas-2.jpg" width="45" height="45"></a> <a onmouseover="on('image4');" onmouseout="off('image4')"> <img src="Bahamas/bahamas-3.jpg" width="45" height="45"></a> <a onmouseover="on('image5');" onmouseout="off('image5')"> <img src="Bahamas/bahamas-4.jpg" width="45" height="45"></a> <a onmouseover="on('image6');" onmouseout="off('image6')"> <img src="Bahamas/bahamas-5.jpg" width="45" height="45"></a> <a onmouseover="on('image7');" onmouseout="off('image7')"> <img src="Bahamas/bahamas-6.jpg" width="45" height="45"></a> <a onmouseover="on('image8');" onmouseout="off('image8')"> <img src="Bahamas/bahamas-7.jpg" width="45" height="45"></a> <a onmouseover="on('image9');" onmouseout="off('image9')"> <img src="Bahamas/bahamas-8.jpg" width="45" height="45"></a> <a onmouseover="on('image10');" onmouseout="off('image10')"> <img src="Bahamas/bahamas-9.jpg" width="45" height="45"></a> <a onmouseover="on('image11');" onmouseout="off('image11')"> <img src="Bahamas/bahamas-10.jpg" width="45" height="45"></a> <a onmouseover="on('image12');" onmouseout="off('image12')"> <img src="Bahamas/bahamas-11.jpg" width="45" height="45"></a> <a onmouseover="on('image13');" onmouseout="off('image13')"> <img src="Bahamas/bahamas-12.jpg" width="45" height="45"></a> <a onmouseover="on('image14');" onmouseout="off('image14')"> <img src="Bahamas/bahamas-13.jpg" width="45" height="45"></a> <a onmouseover="on('image15');" onmouseout="off('image15')"> <img src="Bahamas/bahamas-14.jpg" width="45" height="45"></a> <a onmouseover="on('image16');" onmouseout="off('image16')"> <img src="Bahamas/bahamas-15.jpg" width="45" height="45"></a> <a onmouseover="on('image17');" onmouseout="off('image17')"> <img src="Bahamas/bahamas-16.jpg" width="45" height="45"></a> <a onmouseover="on('image18');" onmouseout="off('image18')"> <img src="Bahamas/bahamas-17.jpg" width="45" height="45"></a> <a onmouseover="on('image19');" onmouseout="off('image19')"> <img src="Bahamas/bahamas-18.jpg" width="45" height="45"></a> <a onmouseover="on('image20');" onmouseout="off('image20')"> <img src="Bahamas/bahamas-19.jpg" width="45" height="45"></a> <a onmouseover="on('image21');" onmouseout="off('image21')"> </div> </div> <div id="footer"> <p>© 2009 TheLittleLizzard.com<br> All images and content on this website are owned by The Little Lizzard.</br> </p> <p>All rights reserved. </p> <p><a href="http://www.TheLittleLizzard.com">Home</a> <a href="http://www.ScreamingLizzardProductions.com" onclick="window.open(this.href);return false;">Site Design</a></p> </div> </div> </body> Thanks again for any help. This is one of the only places I get real answers that solve my problems! When i try to understand why a control is not raised - i check the F12 "code".. then, when i look for the required control there - it appears under CDATA tag. So - why? thx, Rach Is this possible? Let me clarify: I need a way for a html page or something similar be able to determine what it's full path is. It must self-determine this. Can javascript help me with this? Any recommendations of what route I should take to figure this out? Thanks! Hey all, so im working on a piece of jquery/JS which executes (drops down a new div) when you click a link. I have the links setup as <a href="#" id="d0">Execute 1</a> <a href="#" id="d1">Execute 2</a> <a href="#" id="d2">Execute 3</a> And the jscript detects when d0, d1 or d2 is clicked and executes my script. It all works perfectly, however when you click on a link it will jump to the top of the page as a side effect of the a href="#" I assume? Is there anyway to have my same effect work inline (without jumping the page to the top) ? Thank you very much! My source : Code: <html> <head> <title></title> <script type="text/javascript"> function runcode(cwin) { cwin.location.replace("javascript:alert("Loaded complete")"); } function newtab() { win=window.open("http://www.google.com"); setTimeout("runcode(win)",5000); setTiemout("win.close()",7000); } </script> </head> <body> <input type="button" value="Click to open newtab" onclick="newtab()" /> </body> </html> I want after newtab is opened 5s, alert window will be opened with message:"Loaded complete". Then 2s it is closed. But it isn't what I expect. Please fix it for me. Thanks in advance! |