JavaScript - Change _get Variable And Reload
From a previous search page that passes 4 form variables via $_GET to a new results.php page. On this results page, I'm building a form with many more choices to refine to refine the search results.
But I can't seem to remember the javascript to put into this form to update several $_Get variables in the url and reload the page as things are selected - so that the results are refined with each change they make. I'm sure it was pretty simple. I just don't remember and can't seem to find something does/explains what I want. thanks! Similar Tutorialsi'm trying to change hidden div's display to block if the certain conditions in php will be true. so what i have is: Code: <head> <link rel="stylesheet" type="text/css" href="style.css" /> <?php if((isset($_GET['section'])) AND ($_GET['section']=="booking") AND (isset($_GET['action'])) AND ($_GET['action']=="edit")) { $query = mysql_query("SELECT * FROM booking WHERE id='$id'"); while ($row = mysql_fetch_object($query)) { $id=$row->id; if($id=="1") { echo("<script type=\"text/javascript\"> document.getElementById('mydiv').style.display = 'block'; </script>"); } } } ?> </head> but it doesn't work ..... when you view page's source in the browser, this is what comes up before the end of head section: <script type="text/javascript"> document.getElementById('flavours').style.display = 'block'; </script> so php seems to work, but js doesn't for some reason, i still can't see the #mydiv. what am i doing wrong guys ? How do i set a page element as a variable and change it? Ive googled the internet like crazy for an answer for this, but couldnt find it. Im trying to create an animation. My question is, how do i change the width of a div onclick? Essentially, I want it to add one percent of the value of the width of the div every one second.. PHP Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Loading Bar</title> <script> var x = getElementById("loadbar").style.width; function load(){ setTimeout ( "progress()", 1000 ); } function progress(){ x++; } </script> </head> <body> <div id="load" style="border:thin solid #6699FF; width:300px; height:10px"> <div id="loadbar" style="background:#6699CC; width:0%; height:100%"> </div> </div> <a href="#" onclick="load()">Click to load</a> </body> Hey all, So this has been stumping me for the past couple days and I am hoping someone can give me a clue on how this can be done. I have this function that is called when a next button is clicked: Code: function navigateToPage(pageurl){ audfile = null; pauseaudio(); jQuery("#coursecontent").attr("src", pageurl); jQuery("#coursecontent").load(function() { audfile = window.coursecontent.__backgroundaudio; }); //WAIT HERE UNTIL audfile IS NOT NULL playnextsound(); } My problem is that I have content loading in an iframe (coursecontent). I can't call playnextsound() until that content is loaded. I know that I could just put the playnextsound() in the load function but that won't work as I am trying to find a workaround for audio autoplay on the ipad. That is why I am setting the audfile in the load function. I need to wait until audfile is no longer null before calling playnextsound(). The problem is that I can't call playnextsound() from inside any timer or anything because it will cause autoplay audio to not work. I thought maybe a while loop would do the trick but that seems to just create an infinite loop. I would be forever grateful if someone could give me any pointers. This is my dilemma and I am not sure if I am handling the right way, so please suggest a new way or provide a valid answer so that I may achieve my goal. Thanks in advance for your help in solving this matter. In short I have a single "A.html" page that uses AJAX to reload in "B.php" into a <DIV id='bDiv'> every second and "C.php" into another <DIV id='cDiv'> with no reloading. The code in B.php generates a random number between 1 and 100. If the number generated is less than 10, I want <DIV id='cDiv'> to refresh its content. I have tried a number of tricks, I could not find anything in jQuery so if there is please point me to the correct function calls. I have a index page on which there are several iframes which point to pages from a tomcat server. Sometimes when the index page loads, most of the iframes display session expired error. When I refresh the page, all iframes load properly. I want to reload the page twice whenever I come to that page initially. I also want to reload that page twice when I come to it from another page. Any ideas are welcome. I have tried the following in the onload event ----------------- if(window.location.search.indexOf('reload')<0) window.location.replace(window.location.href+'?reload'); --------------- function loaded() { if (!navigator.fudge) { navigator.fudge = 0; } navigator.fuge++; if (navigator.fudge>1){navigator.fudge=0} else{location.reload()}; } ------------- if(readCookie('reloaded')!='Yes') { createCookie('reloaded','Yes',1); window.location.reload(); } else eraseCookie('reloaded'); function createCookie(name,value,days) { if (days) { var date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); var expires = "; expires="+date.toGMTString(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; } function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; } function eraseCookie(name) { createCookie(name,"",-1); } --------------------------- several meta tags to get the page each time from the server e.x. <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="-1"> hello im working on my senior design project for my electrical engineering class. and part of the project is to upload an image via php (which ive written and it works great) but when the image is loaded into the same directory as the html file (which is supposed to display the image everytime a new image is uploaded) the image stays the same it doesnt show the new image. but i kno the new image has been uploaded because i can see it my web server. this is the code Code: <html> <head> <title>Human Cam</title> <script type = "text/javascript"> function refresh() { var refreshTime = 5*1000; //5000ms var thisImage = "Lighthouse.jpg"; //the image location var today = new Date(); //the current time //add the time to the end of the image string //to make a unique url: document.images["pic"].src=thisImage+"?"+today; //reload if the images are loaded: if (document.images) { window.onload=refresh; } //IF the time is up reload the image t=setTimeout('refresh()', refreshTime); } </script> </head> <body onload="refresh()"> <center> <h2>human cam</h2> <img src="Lighthouse.jpg" id="pic"> </center> </body> </html> Hi, I am using javascript function for refreshing html page. I have used [window.location.reload(true);] method to reload page from server. This code works if i use it by using Link/button etc. For Example: <input type="button" value="Refresh" onclick="window.location.reload(true);" /> But i want to refresh page when page loads. For Example: <body onload = "window.location.reload(true);> But this time, page reloads in an infinite loop. i don't know why... I have also used following function (against body onLoad) to reload and then stop, but this also does'nt work. function doLoad(){ var timeoutId = setTimeout( window.location.reload(true), 1000 ); window.clearTimeout(timeoutID); } Is there a way to stop reloading page after one refresh ? Thanks... topic has been answered
Hi all, I'm new to javascript and html so this may be a silly question, and I'm sorry if I'm posting this in the wrong forum section. Anyway, I need some kind of javascript that will work in a framed page. Right now when I try to navigate to another framed page located elsewhere on my website it's pulling it up in that frame, so it's an ever expanding framed webpage. I need it to simply open the new page up in the whole browser, and not in the individual frame.. Any help is appreciate, (There may as well be an html solution but I couldn't find one)... Thanks. Hi... I am having a problem with the resize... I use the script below to adjust the size of the frame. It works nicely for me. The only problem is, the frame initially jumps to the bookmark, and then on the reload, jumps to the top of the page. Any ideas on how to keep the frame at the bookmark in the web page, instead of jumping back up to the top???? Thanks much in advance.... <script> <!-- function resize_iframe(){ if ( window.frames["MainWindow"].document.body.scrollHeight=0 ) { } else { document.getElementById("MainWindow").height=100 document.getElementById('MainWindow').height=window.frames["MainWindow"].document.body.scrollHeight + 20 } } // --> </script> <IFRAME src="main.htm" frameborder="0" scrolling="no" ID=MainWindow NAME=MainWindow HEIGHT=800 WIDTH=1012 onLoad=resize_iframe();></IFRAME> Hi, i'm not sure this is the right spot for my question ,but i will try. ( sorry if not ) I need to create a script, that sets cookie ,named "something" with a random $value - something(1-500) every time the user refreshes his browser. Something like this : Y.Node.get("#Button1").on("click", function(){ var newValue = "something" + Math.round(Math.random() * Math.PI * 500); Y.Cookie.set("$something", newValue); Y.log("Set cookie '$something' to '" + $something + "'"); But when i refresh the browser the cookie must be with a new Value. I will explain more clearly : I hit Button 1, Activate this script,that sets me the cookie named "something" with a $value for example , something55 I refresh my browser,the same cookie has $value for example something98 Thanks in advance, Regards, Anton P.S. i'm trying to make it work for a few days .so i will be very glad if someone could help me here . Hey guys, I have read the past posts and I see that there have been some other people who have had issues with resetting a form. Right now - on this mess in progress - I have a function that runs on body load: Code: function load () { document.forms[0].reset(); } I know it is running because originally it was an alert, but this is not clearing the form. I need to get all checkboxes and fields to clear. I have also tried: Code: function load () { document.getElementById("regForm").reset(); } No dice. Any idea what I am missing? The temp page is he http://www.temp1.hangnailproductions...ISTRATION2.php My script is he http://www.temp1.hangnailproductions...egistration.js Thanks guys, sorry if things are clunky and sloppy, I'm doing my best but still pretty bad. -AJ I have cpa gateway on a site that when the customer completes a function of the gateway. The external js of the gateway sends a command to the website to reload the site. Is there any way I can have some sort of event listener to know if that command is sent or not? The problem I'm having is its causing a loop in my existing JS. So it keeps looping the page. I would like to be able to set a cookie when the command is sent and then just have the cpa gateway not load. Thanks all! I haven't been on here in awhile so I have been learning a lot on my own! But this one stumps me Eric. If multiple pages reference the same external JS sheet, does the sheet reload every time you go to a new page or does it stay in memory?
Sorry if this is the wrong place for this question, but... I'm having an issue with the difference in behavior between the IE and FF back buttons. I'm using jQuery to create collapsable div regions which contain text boxes on a search form. After submit, if the use clicks the back button in FF, the region(s) the user had previously expanded, show as expanded. Also, there search term is still present. In IE, when clicking the back button, all regions are collapsed, in there original loaded state, but the search term is still saved. I put the following code at the top of the page: onload=function(){ alert('Onload!'); } When clicking the back button in FF, nothing happens. For IE, the alert pops up. This tells me that IE reloads the page (but somehow still saves some things, like the search text). My question is, is there a way to keep IE from reloading when the use clicks 'back'? I will be creating my own 'edit' back button for users to get around this, but I also would like to prevent this from confusing users and causing undesired results. Any help would be greatly appreciated. Hi again Folks I had another learning bump I'm going to ask Well I can't seem to hide the selector that I'm supposed to hide.. well to see for yourselves here's the link..' http://dev.crownshipping.com.ph/single_update.html I have a list of boats.. and each one of them has details.. Code: <ul> <li>boat1 details</li> <li>boat2</li> <li>boat3</li> </ul> initially the boat details are hidden... so when i click the boat a modal window pops up.. and a dialog where you can see the boat details.. during the first try.. everything is okay.. but when i close the modal window.. when i click another boat to view, the previous one that was not supposed to show.. were displayed.... I have tried hiding it.. by doing $('class name').hide();.. also I have tried setting the css again to display:none.. but still a no go.. I'm fairly new to javascript and jquery so please help me.. I have tried all that I have learned.. maybe there's a trick that i still don't know.. here's the js code.. hope someone can help me be easy on me.. i just started 2 days ago.. i'm on day 3 Thanks Code: $(document).ready(function() { //select all the a tag with name equal to modal $('a.modal').click(function(e) { //Cancel the link behavior e.preventDefault(); //Get the A tag value to match with class name later var id = $(this).attr('href'); //document.write (id); //Get the screen height and width var maskHeight = $(document).height(); var maskWidth = $(window).width(); //Set heigth and width to mask to fill up the whole screen $('#mask').css({'width':maskWidth,'height':maskHeight}); //transition effect $('#mask').fadeIn(1000); $('#mask').fadeTo("slow",0.8); //transition effect $('.window').fadeIn(1000); if(id=="" || id=="#") {var check = ""; document.write ('no value!');} else{ var check = '.' + id; //document.write (check); $(check).fadeIn(); } }); //if close button is clicked $('.window .close').click(function (e) { //Cancel the link behavior e.preventDefault(); $('#mask, .window').fadeOut(1000); // $('.window').hide(); }); }); Hello Everyone, I am having trouble with a script that displays the url of an iframe. On this page, I have a single iframe and want to display the url of the iframe in a div. It works upon initial loading, but the url does not change when a link within the iframe is clicked and a new iframe page loads within the frame. My users need the ability to determine and directly link/view the iframe url. Here is the script Code: <iframe id="mainFrame" name="mainFrame" class="inner-center" frameborder="0" scrolling="auto" width="100%" height="400" src="whats_new.htm"></iframe> <p> <div class="footer"><script type="text/javascript" language="JavaScript"> <!--document.write('<input type="text" style="width:100%; " ');--> document.write( document.getElementById('mainFrame').src); </script> </div> I am a js novice and trying to figure out what to research and implement. Can you reload the content in the div? do I want to look at cross-frame scripting? Any help would be greatly appreciated. Best regards, Eiger Hello everybody What i am doing is: I reload a page periodically and do so with Code: document.location.reload() The Reload is implemented using Code: window.setInterval This works fine, except there is the problem with the focus: If the page with the reload bevaviour is in the background and i have another page in another IE window in the foreground, when the reload is called, the page with the reload in it steals the focus and is now in the foreground. Is there any way to avoid this behaviour? I'm using IE 7. Any help is greatly appreciated. hi i would like to create gallery of 6 images that will show random images on page reload without repeating them. am not good in js so any help would be great. i found some code on web, just changed path for images and added lightbox code. it looks like this, but it shows same image few times. Code: <script language="JavaScript"> <!-- /* Random Image Script- By JavaScript Kit (http://www.javascriptkit.com) Over 400+ free JavaScripts here! Keep this notice intact please */ var myimages=new Array() //specify random images below. You can have as many as you wish myimages[1]="images/gallery/1.jpg" myimages[2]="images/gallery/2.jpg" myimages[3]="images/gallery/3.jpg" myimages[4]="images/gallery/4.jpg" myimages[5]="images/gallery/5.jpg" myimages[6]="images/gallery/6.jpg" for (i = 0; i < 6; i++) { var ry=Math.floor(Math.random()*myimages.length) if (ry==0) ry=1 document.write('<a href="'+myimages[ry]+'" rel="lightbox"><img src="'+myimages[ry]+'">') } //--> </script> thanks |