JavaScript - Prevent Page Refresh On Chkbox Clicking
hi please help solving my problem. I have the following code for changing the td colour when chk box in it is clicked. It is working fine. My application will get some data from the database when i check a chk box say ABC. My problem is ...i want to chage the colour of the check box when it is clicked and retain the colour of my chkbox even after page refresh.
Code: <html> <head> <title>color</title> <script type="text/javascript"> function toggle(box,theId) { if(document.getElementById) { var cell = document.getElementById(theId); if(box.checked) { cell.className = "on"; } else { cell.className = "off"; } } } </script> <style type="text/css"> .off { background-color: #fff; } .on { background-color: red; } </style> </head> <body> <table border="1" cellpadding="5" cellspacing="0"> <tr> <td class="off" id="sub1"><input type="checkbox" name="subject" onclick="submit(); toggle(this,'sub1'); " value="s1" id="demo1">ABC</td> <td class="off" id="sub2"><input type="checkbox" name="subject" onclick=" submit(); toggle(this,'sub2'); " value="s2" id="demo2">XYZ</td> </tr> </table> </body> </html> Reply With Quote 01-21-2015, 08:37 AM #2 Philip M View Profile View Forum Posts Supreme Master coder! Join Date Jun 2002 Location London, England Posts 18,371 Thanks 204 Thanked 2,573 Times in 2,551 Posts Originally Posted by raj_d hi please help solving my problem. I have the following code for changing the td colour when chk box in it is clicked. It is working fine. My application will get some data from the database when i check a chk box say ABC. My problem is ...i want to chage the colour of the check box when it is clicked and retain the colour of my chkbox even after page refresh. You will need to use a cookie or local storage to record the colour of the checkbox. Similar TutorialsI tried to word the question as best as possible, but here is what I want to do. I am creating a calculator online and it is getting more and more extensive, which is good b/c I'm learning a lot. Here is what I'm trying accomplish now. I am using "input" to get information from the user in the top section of my calculator and that will always stay the same. The part that will change is the results section (bottom part of the calc) based on a few different variations or setups, so I want to be able have them click on a few different options. Option 1 Option 2 Option 3 Depending on which one they click I want the javascript that is run for the results section to correspond to the option chosen. I also, want to be able to have a default option displayed the first time the page is loaded and then have it change if a different option is chosen. I don't think reloading the page is necessary, but I'm new to this and could use a little direction. I hope what I'd like to do makes a little sense. I'm not asking for any code written that will do this, but naturally something hints or tips that could get me going. I don't know how to "monitor" a link and return a value to a variable, so that it can be put into a an if statement in the results section. After that, it would be continually monitored or somehow restarted if the variable does change. Again, I don't know if this is the best way to go at it, but I'm not sure at all. Any help would be awesome. I have looked at "onclick", but I'm not completely sure how I can tie it all together of if I should use another method. Thanks for any suggestions/ideas/help. Hi, this is my first post on the forum. I was just wondering whether there is a way to hide an element on another page after clicking on a button? Basically, I have a login page, and for testing purposes, I want it so when you click a button, it runs some javascript in a file called ajax.util.js, and I have a jQuery file attached to the HTML file as well (http://ajax.googleapis.com/ajax/libs.../jquery.min.js), and I am using Google App Engine, which im not sure whether thats relevant. I tried using the show and hide functions provided by the jQuery file, but no luck, i want to hide an element which is a link with ID admintools. I have also tried getting the element by ID and changing the display style to none and hidden but still no luck. Im not sure whether its only possible to hide elements in the login.html page. What I want it to do basically is click on the submit button in the login page, it will then run a javascript function which redirects you to index.html (which i am doing using window.location), and then hides an element in the index.html page (id=admintools). Any help would be great, Thanks in advance Hi all, I am facing problem in preventing my web page being loaded into an iFrame. I search in internet and found this solution : if (self == top) document.documentElement.style.display = 'block'; else top.location = self.location; The above java script code is simple redirecting me to the home page of my web site. But I donot want that kind of solution. When anybody tried to access my web page through iFrame, it should show an error message like "The content of the web site cannot be loaded into an IFrame". This message should be displayed inside the iFrame. For example, if we tried to access "google.com" site in an iframe, the website should not allow the iframe object to load into it, insted it will display an error message along with a provision to open webiste with an external link with it. Any help? thanks, -Sanath Hello guys, You were all very kind to help me a few months ago when I was trying to create the code which is posted below. it is a table of banner ads that will rotate on my website and the appropriate link follows the appropraite ad when they rotate. everything is working fine except that when you click on one of the ads ( which is a link), the link works but the page displays an error at the bottom as soon as any link is clicked. Since this type of hyperlink is associated with the javascript, im not sure how to correct the issue. maybe it is a simple thing. can anyone take a look at this and help me figure out the issue? thanks. 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=utf-8" /> <title>.</title> <script type="text/javascript"> var ImageArray = [ // add paths, if needed ['randoms/0.jpg','http://0.com'], ['randoms/1.jpg','http://1.com'], ['randoms/2.jpg','http://2.com'], ['randoms/3.jpg','http://3.com'], ['randoms/4.jpg','http://4.com'], ['randoms/5.jpg','http://5.com'], ['randoms/6.jpg','http://6.com'], ['randoms/7.jpg','http://7.com'], ['randoms/8.jpg','http://8.com'], ['randoms/9.jpg','http://9.com'], ['randoms/10.jpg','http://10.com'], ['randoms/11.jpg','http://11.com'], ['randoms/12.jpg','http://12.com'], ['randoms/13.jpg','http://13.com'], ['randoms/14.jpg','http://14.com'], ['randoms/15.jpg','http://15.com'] // No comma after last entry ]; function randOrd() { return (Math.round(Math.random())-0.5); } function ChangeImages() { var ImgPtr = new Array(); for (var i=0; i<ImageArray.length; i++) { ImgPtr[i] = i; } ImgPtr = ImgPtr.sort(randOrd); var tmp = ''; for (var i=0; i<ImgPtr.length; i++) { tmp = 'tImg'+i; document.getElementById(tmp).src = ImageArray[ImgPtr[i]][0]; document.getElementById(tmp).alt = ImageArray[ImgPtr[i]][1]; tmp = 'lImg'+i; document.getElementById(tmp).href = ImageArray[ImgPtr[i]][1]; } } var TimerAction = 0; function startTimer() { TimerAction = setInterval('ChangeImages()',3000); } function stopTimer() { clearTimeout(TimerAction); } </script> <style type="text/css">body { background-color: #000000; margin: 0; } </style></head> <body onLoad="startTimer();ChangeImages()" > <table width="250" border="0" cellpadding="0" id="ads"> <tr><td> <a href="" id="lImg0" onclick="return gotoLink(this.id,0)"target="_blank"> <img id="tImg0" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg1" onclick="return gotoLink(this.id,1)"target="_blank"> <img id="tImg1" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg2" onclick="return gotoLink(this.id,2)"target="_blank"> <img id="tImg2" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg3" onclick="return gotoLink(this.id,3)"target="_blank"> <img id="tImg3" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg4" onclick="return gotoLink(this.id,4)"target="_blank"> <img id="tImg4" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg5" onclick="return gotoLink(this.id,5)"target="_blank"> <img id="tImg5" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg6" onclick="return gotoLink(this.id,6)"target="_blank"> <img id="tImg6" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg7" onclick="return gotoLink(this.id,7)"target="_blank"> <img id="tImg7" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg8" onclick="return gotoLink(this.id,8)"target="_blank"> <img id="tImg8" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg9" onclick="return gotoLink(this.id,9)"target="_blank"> <img id="tImg9" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg10" onclick="return gotoLink(this.id,10)"target="_blank"> <img id="tImg10" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg11" onclick="return gotoLink(this.id,11)"target="_blank"> <img id="tImg11" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg12" onclick="return gotoLink(this.id,12)"target="_blank"> <img id="tImg12" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg13" onclick="return gotoLink(this.id,13)"target="_blank"> <img id="tImg13" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg14" onclick="return gotoLink(this.id,14)"target="_blank"> <img id="tImg14" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> <tr><td> <a href="" id="lImg15" onclick="return gotoLink(this.id,15)"target="_blank"> <img id="tImg15" src="" alt="" width="250" height="166"> </a> </td></tr> <tr> <td> </td> </tr> </table> </body> </html> I am using the following code from this site... http://www.javascriptkit.com/script/...selector.shtml but for some reason if the page is long the whole page scrolls up so the top of the calendar is at the top of the browser, which actually hides the box that the date will end up in. can anyone see how I can alter the code so that the page does not scroll up, but have the calendar show just below the box that the date will go in and the page does not scroll? here is the full code that I am using to test this out with. Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> .ds_box { background-color: #FFF; border: 1px solid #000; position: absolute; z-index: 32767; } .ds_tbl { background-color: #FFF; } .ds_head { background-color: #333; color: #FFF; font-family: Arial, Helvetica, sans-serif; font-size: 13px; font-weight: bold; text-align: center; letter-spacing: 2px; } .ds_subhead { background-color: #CCC; color: #000; font-size: 12px; font-weight: bold; text-align: center; font-family: Arial, Helvetica, sans-serif; width: 32px; } .ds_cell { background-color: #EEE; color: #000; font-size: 13px; text-align: center; font-family: Arial, Helvetica, sans-serif; padding: 5px; cursor: pointer; } .ds_cell:hover { background-color: #F3F3F3; } /* This hover code won't work for IE */ </style> </head> <body> <table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;"> <tr><td id="ds_calclass"> </td></tr> </table> <script> // <!-- <![CDATA[ // Project: Dynamic Date Selector (DtTvB) - 2006-03-16 // Script featured on JavaScript Kit- http://www.javascriptkit.com // Code begin... // Set the initial date. var ds_i_date = new Date(); ds_c_month = ds_i_date.getMonth() + 1; ds_c_year = ds_i_date.getFullYear(); // Get Element By Id function ds_getel(id) { return document.getElementById(id); } // Get the left and the top of the element. function ds_getleft(el) { var tmp = el.offsetLeft; el = el.offsetParent while(el) { tmp += el.offsetLeft; el = el.offsetParent; } return tmp; } function ds_gettop(el) { var tmp = el.offsetTop; el = el.offsetParent while(el) { tmp += el.offsetTop; el = el.offsetParent; } return tmp; } // Output Element var ds_oe = ds_getel('ds_calclass'); // Container var ds_ce = ds_getel('ds_conclass'); // Output Buffering var ds_ob = ''; function ds_ob_clean() { ds_ob = ''; } function ds_ob_flush() { ds_oe.innerHTML = ds_ob; ds_ob_clean(); } function ds_echo(t) { ds_ob += t; } var ds_element; // Text Element... var ds_monthnames = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; // You can translate it for your language. var ds_daynames = [ 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat' ]; // You can translate it for your language. // Calendar template function ds_template_main_above(t) { return '<table cellpadding="3" cellspacing="1" class="ds_tbl">' + '<tr>' + '<td class="ds_head" style="cursor: pointer" onclick="ds_py();"><<</td>' + '<td class="ds_head" style="cursor: pointer" onclick="ds_pm();"><</td>' + '<td class="ds_head" style="cursor: pointer" onclick="ds_hi();" colspan="3">[Close]</td>' + '<td class="ds_head" style="cursor: pointer" onclick="ds_nm();">></td>' + '<td class="ds_head" style="cursor: pointer" onclick="ds_ny();">>></td>' + '</tr>' + '<tr>' + '<td colspan="7" class="ds_head">' + t + '</td>' + '</tr>' + '<tr>'; } function ds_template_day_row(t) { return '<td class="ds_subhead">' + t + '</td>'; // Define width in CSS, XHTML 1.0 Strict doesn't have width property for it. } function ds_template_new_week() { return '</tr><tr>'; } function ds_template_blank_cell(colspan) { return '<td colspan="' + colspan + '"></td>' } function ds_template_day(d, m, y) { return '<td class="ds_cell" onclick="ds_onclick(' + d + ',' + m + ',' + y + ')">' + d + '</td>'; // Define width the day row. } function ds_template_main_below() { return '</tr>' + '</table>'; } // This one draws calendar... function ds_draw_calendar(m, y) { // First clean the output buffer. ds_ob_clean(); // Here we go, do the header ds_echo (ds_template_main_above(ds_monthnames[m - 1] + ' ' + y)); for (i = 0; i < 7; i ++) { ds_echo (ds_template_day_row(ds_daynames[i])); } // Make a date object. var ds_dc_date = new Date(); ds_dc_date.setMonth(m - 1); ds_dc_date.setFullYear(y); ds_dc_date.setDate(1); if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) { days = 31; } else if (m == 4 || m == 6 || m == 9 || m == 11) { days = 30; } else { days = (y % 4 == 0) ? 29 : 28; } var first_day = ds_dc_date.getDay(); var first_loop = 1; // Start the first week ds_echo (ds_template_new_week()); // If sunday is not the first day of the month, make a blank cell... if (first_day != 0) { ds_echo (ds_template_blank_cell(first_day)); } var j = first_day; for (i = 0; i < days; i ++) { // Today is sunday, make a new week. // If this sunday is the first day of the month, // we've made a new row for you already. if (j == 0 && !first_loop) { // New week!! ds_echo (ds_template_new_week()); } // Make a row of that day! ds_echo (ds_template_day(i + 1, m, y)); // This is not first loop anymore... first_loop = 0; // What is the next day? j ++; j %= 7; } // Do the footer ds_echo (ds_template_main_below()); // And let's display.. ds_ob_flush(); // Scroll it into view. ds_ce.scrollIntoView(); } // A function to show the calendar. // When user click on the date, it will set the content of t. function ds_sh(t) { // Set the element to set... ds_element = t; // Make a new date, and set the current month and year. var ds_sh_date = new Date(); ds_c_month = ds_sh_date.getMonth() + 1; ds_c_year = ds_sh_date.getFullYear(); // Draw the calendar ds_draw_calendar(ds_c_month, ds_c_year); // To change the position properly, we must show it first. ds_ce.style.display = ''; // Move the calendar container! the_left = ds_getleft(t); the_top = ds_gettop(t) + t.offsetHeight; ds_ce.style.left = the_left + 'px'; ds_ce.style.top = the_top + 'px'; // Scroll it into view. ds_ce.scrollIntoView(); } // Hide the calendar. function ds_hi() { ds_ce.style.display = 'none'; } // Moves to the next month... function ds_nm() { // Increase the current month. ds_c_month ++; // We have passed December, let's go to the next year. // Increase the current year, and set the current month to January. if (ds_c_month > 12) { ds_c_month = 1; ds_c_year++; } // Redraw the calendar. ds_draw_calendar(ds_c_month, ds_c_year); } // Moves to the previous month... function ds_pm() { ds_c_month = ds_c_month - 1; // Can't use dash-dash here, it will make the page invalid. // We have passed January, let's go back to the previous year. // Decrease the current year, and set the current month to December. if (ds_c_month < 1) { ds_c_month = 12; ds_c_year = ds_c_year - 1; // Can't use dash-dash here, it will make the page invalid. } // Redraw the calendar. ds_draw_calendar(ds_c_month, ds_c_year); } // Moves to the next year... function ds_ny() { // Increase the current year. ds_c_year++; // Redraw the calendar. ds_draw_calendar(ds_c_month, ds_c_year); } // Moves to the previous year... function ds_py() { // Decrease the current year. ds_c_year = ds_c_year - 1; // Can't use dash-dash here, it will make the page invalid. // Redraw the calendar. ds_draw_calendar(ds_c_month, ds_c_year); } // Format the date to output. function ds_format_date(d, m, y) { // 2 digits month. m2 = '00' + m; m2 = m2.substr(m2.length - 2); // 2 digits day. d2 = '00' + d; d2 = d2.substr(d2.length - 2); // YYYY-MM-DD // return y + '-' + m2 + '-' + d2; return d2 + '-' + m2 + '-' + y; } // When the user clicks the day. function ds_onclick(d, m, y) { // Hide the calendar. ds_hi(); // Set the value of it, if we can. if (typeof(ds_element.value) != 'undefined') { ds_element.value = ds_format_date(d, m, y); // Maybe we want to set the HTML in it. } else if (typeof(ds_element.innerHTML) != 'undefined') { ds_element.innerHTML = ds_format_date(d, m, y); // I don't know how should we display it, just alert it to user. } else { alert (ds_format_date(d, m, y)); } } // And here is the end. // ]]> --> </script> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <form action="" method="post"> <div> <b>Example Form</b><br/> Please input a date: <input onclick="ds_sh(this);" name="date" readonly="readonly" style="cursor: text" /><br /> Please input another date: <input onclick="ds_sh(this);" name="date2" readonly="readonly" style="cursor: text" /><br /> <input type="submit" value="Submit" /> </div> </form> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> <br> </body> </html> Code is triggered on the following page when mouse position leaves a profile link while logged in: http://www.veinsfetiche.com/forums/ Code: <script type="text/javascript"> // <![CDATA[ // show the popup function show_popup(UserID) { if(http_getuser) { //get user data and show popup sendRequest(UserID); } } // hide the popup function close_popup() { document.getElementById('popup').style.display='none'; } // Make the request function createRequestObject() { if(window.XMLHttpRequest){ ro = new XMLHttpRequest(); } else if(window.ActiveXObject) { ro = new ActiveXObject("Msxml2.XMLHTTP"); if(!ro) { ro = new ActiveXObject("Microsoft.XMLHTTP"); } } return ro; } //Create Request Variables var http_getuser = createRequestObject(); //Send Request for user info function sendRequest(UserID) { var userinfo_url = '{AJAX_USERINFO_PATH}'; http_getuser.open('get', userinfo_url.replace('USERID', UserID)); http_getuser.onreadystatechange = handleResponse; http_getuser.send(null); } // fill in the response function handleResponse() { if(http_getuser.readyState == 4 ){ var xmlDoc = http_getuser.responseXML; if(xmlDoc.hasChildNodes()) { document.getElementById('ajax_username').innerHTML = xmlDoc.getElementsByTagName('username')[0].firstChild.nodeValue; document.getElementById('ajax_registert').innerHTML = xmlDoc.getElementsByTagName('regdate')[0].firstChild.nodeValue; document.getElementById('ajax_posts').innerHTML = xmlDoc.getElementsByTagName('posts')[0].firstChild.nodeValue; document.getElementById('ajax_website').innerHTML = xmlDoc.getElementsByTagName('website')[0].firstChild.nodeValue; document.getElementById('ajax_from').innerHTML = xmlDoc.getElementsByTagName('from')[0].firstChild.nodeValue; document.getElementById('ajax_last_visit').innerHTML = xmlDoc.getElementsByTagName('lastvisit')[0].firstChild.nodeValue; document.getElementById('ajax_rank').innerHTML = xmlDoc.getElementsByTagName('rank')[0].firstChild.nodeValue; document.getElementById('ajax_avatar').innerHTML = xmlDoc.getElementsByTagName('avatar')[0].firstChild.nodeValue; //document.getElementById('ajax_add').innerHTML = xmlDoc.getElementsByTagName('add')[0].firstChild.nodeValue; //Apply style which makes profile info visible document.getElementById('popup').style.display='block'; //Get height of popup var getRefById = function() {return null;}; if(document.getElementById) { getRefById = function(i) {return document.getElementById(i);}; } else if(document.all) { getRefById = function(i) {return document.all[i] || null;}; } var d = getRefById('popup'), h = '0px', o; if(d) { if((o = document.defaultView) && o.getComputedStyle) { h = o.getComputedStyle(d, null).height; } else if('number' == typeof d.offsetHeight) { h = d.offsetHeight + 'px'; } } // 'h' should now contain the height of 'myDiv', or 0px //alert(h); //make room for popup document.getElementById('test').style.height= h; } } } // set popup to mouse possition function set_div_to_mouse(e) { //Make x and y cord vars var docX, docY; //get page info if(e) { if(typeof(e.pageX) == 'number') { docX = e.pageX; docY = e.pageY;} else {docX = e.clientX; docY = e.clientY;} //vert } else { e = window.event; docX = e.clientX; docY = e.clientY; if(document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) { docX += document.documentElement.scrollLeft; docY += document.documentElement.scrollTop; } else if(document.body && (document.body.scrollTop || document.body.scrollLeft)) { docX += document.body.scrollLeft; docY += document.body.scrollTop; } } //hor if (docX > document.body.offsetWidth - 400) { document.getElementById('popup').style.left = (docX - 350) + "px"; } else { document.getElementById('popup').style.left = (docX - 5) + "px"; } document.getElementById('popup').style.top = (docY + 30) + "px"; } //document.onmousemove = set_div_to_mouse; // ]]> </script> <div id="test"> <div class="forabg" id="popup" style="width: 90%;"> <div class="inner"> <span class="corners-top"><span></span></span> <ul class="topiclist fullwidth"> <li class="header"><dl><dt>{L_READ_PROFILE}</dt></dl></li> </ul> <ul class="topiclist forums"> <li><dl> <dd style="width:100%"> <table> <tr> <td><div id="ajax_avatar"></div></td> <td><strong>{L_USERNAME}:</strong> <span id="ajax_username"></span><br /> <strong>{L_TOTAL_POSTS}:</strong> <span id="ajax_posts"></span><br /> <strong>{L_SORT_RANK}:</strong> <span id="ajax_rank"></span><br /> <strong>{L_JOINED}:</strong> <span id="ajax_registert"></span><br /> <strong>{L_LAST_VISIT}:</strong> <span id="ajax_last_visit"></span><br /> <strong>{L_LOCATION}:</strong> <span id="ajax_from"></span><br /> <strong>{L_WEBSITE}:</strong> <span id="ajax_website"></span><br/> <span id="ajax_add"></span> </tr> </table> <br/ style="clear: both;"> </dd> </dl></li> </ul> <span class="corners-bottom"><span></span></span> </div> </div> </div> When my code hits line 80, the height of a div tag is increased to make room for expanding content, so that the new content does not overlap already existing content. When the div tag's height increases, this increases the overall page height. When the page height increases, then the scroll bar stays in the same place, but the page position changes in the browser. Is there anyway to prevent the viewer's position from changing when room is made for the expanding content? i have a page named pck_rates.php which contains a form that go to the page update_pck_rates.php when i press updade data button in the second page i want the first page to be refreshed to show the new data's. i want to know if i can set a name to the page pck_rates.php and after the update query in the second page i will refresh the pck_rates.php page using this name?? i don't know what is the function and how to make this idea. can anyone help me please Is it possible to change the URL when a page refreshes? E.G Someone clicks a link on index.php to page1.php. When you refresh page1.php it actually loads page2.php The reason i ask my site uses AJAX to change pages (therefore doesnt refresh and stays on the index.php page). So if someone has followed 3-4 links and refreshes the page it will go back to the homepage, i want it so it reloads the currently page (i can use query strings to get the relevant page) Is this possible? I am writing a script that will display an alert box that reads "your play was saved" after a user clicks the submit button on a form. The only problem is that after clicking save, the page refreshes. Here is the code I tried to use Code: function savedMessage(){ document.getElementById("CmdFinish").addEventListener("click",function(e) { GM_setValue("Saved", 1); }, false); if (GM_getValue("saved", 0) == 1) { alert("Your play has been saved"); GM_setValue("saved", 0); // or GM_deleteValue("saved"); } } The button ID is "CmdFinish" and the value is "saved". Is there ANY way i can make the script run only on a page refresh? **Note** The script is for a specific page and not the whole site, so it wont run on every refresh on the site, only when it's needed on 1 page. Hi Guys, Our company own a lot of domains and want to put a short page of copy on each address along with keywords before redirecting the user to our main site. I have been able to get the page to load the main site after the desired time using this code in the head... Quote: <META HTTP-EQUIV="refresh" CONTENT="40;URL=http://webaddress.com/"> That works perfectly, I am now trying to display a countdown timer from 40 seconds down to 0, and on 0 redirect the user. Saying something like "You will be redirected in XX seconds". Is there anyway of doing this? I've been searching google for the answers with no luck and can only seem to find timers that countdown to a set date. Thanks in advance! Ria <HEAD><TITLE>main</TITLE> <meta http-equiv="refresh" content="5;url=http://localhost/php_basic/short_pro/php/main.php"> <!--<script language="JavaScript"> var i=0; function validat() { setTimeout("moretext()",5000); alert("santosh"); } function moretext() { if(i==0) { alert(window.location); window.location.reload(); i++; } else { } } </script>--> </head> <BODY onload="validat();"> i hav written dis code to auto refresh page only once but it is refreshing after every 5 seconds. Earlier i hav wriiten meta tag but it is refreshing page after every 5 seconds & after that i hav wriiten script to auto reffresh page only once but they both r doin the same work,so can u plz help me in solvin my problem How can I write a JavaScript for the following requirement. I have to go to a link say
Quote: www.google.com and refresh it for every 5 seconds continuously. Thanks Hi, For the last few day's i've been searching for a js/ajax div refresh. I need a js/ajax script that refresh a div every 10 seconds or gets menu.php file and updates it. Thanks. Hi For our new site we need to regularly update part of page. What solutions are there for this purpose?? This may be a stupid question, but is there a way to have a page refreshed at a specific time of day? I have made up a page I set as my browser's home page, an electronic Page-A-Day calendar. If I am working on the computer overnight I would like this page to refresh autotically at midnight. I have seen all sorts of posts that describe how to refresh after a certain amount of time has passed, but nothing for what I would like to do. For those interested the code i have for the webpage in in the attached file. Nite Hello! I have been designing a schedule website which will be displayed on several computers throughout the building, I would like to be able to edit the JS during the day but I do not want to be going all through the building refreshing every computer to make sure it has the latest JS version. I also do not want use the meta HTML tag to refresh because that is too noticeable with the images reloading. Basically I would like to only refresh the JS file. I found this link, but it has a button which defeats the purpose. Any way of doing this without the button? FYI, I have the javascript setTimeout("driver()",1000); already so that the clock stays up to date. Not sure if that will make things easier or more complicated... EDIT: not sure why the ICODE tags are not working EDIT 2: Forgot the website! http://www.philnicholas.com/2009/05/...ing-your-page/ hi there. i have a classic asp page that is using the winhttprequest object to get the contents of website from a different server. Then i modify the html i get to suit my needs.. save it to a file, and then finally, i display this stuff in an IFRAME. (i wrapped a div tag around the iframe so technically, i'm doing something like: "divtabframe.innerHTML = '<IFRAME SRC='myserver/somepage.html'></IFRAME>) My problem is that when i refresh the main page, i want the iframe to also display the latest data. It does get the latest data from the external site and its saved in "somepage.html". But the iframe isn't updated unless i explicitly right-click inside the frame and manually select refresh. I have added a <meta http-equiv="refresh" content="30"> line to make it auto refresh on it's own. But the users find it annoying that the page refreshes while they're reading it. It would be ideal if when they refresh the main page, the iframe gets updated too. or i could create a new button too... as long as both pages are updated i did find this solution on a different website: document.getElementById(FrameID).contentDocument.location.reload(true); My page inside the iframe is ultimately "local" so it sounds like the above code should work, but i'm not sure what event would be best to trigger this javascript... and i still need a way to refresh the main page too. thanks. I am running into a problem, that no one else in the world seems to have. When I make a form and submit the page is refreshed, or rather redirected to a state with the values filled after the ? (i.e. http://localhost/comp-267/lab15.html -> http://localhost/comp-267/lab15.html?cardNUm=). I have found solutions that have worked for other people, none of them work for me. I have tested my forms on multiple browsers on multiple systems and the problem persists. Here is one example of my code where this happens. Code: <script type="text/javascript"> function checkCC(myForm) { var ccType; var ccLength; var ccNum = myForm.cardNum.value; if (myForm.cardType.selectedIndex == 0) { ccType = "Visa"; } else if (myForm.cardType.selectedIndex == 1) { ccType = "MasterCard" } else if (myForm.cardType.selectedIndex == 2) { ccType = "AmericanExpress" } switch(ccType) { case "Visa": valid = /^4[0-9]{12}(?:[0-9]{3})?$/; if (valid.test(myForm.cardNum.value)) { alert("This is a Valid Visa Card"); return true; } else { alert("This Card Number is Invalid For Visa"); return false; } break; case "MasterCard": valid = /^5[1-5][0-9]{14}$/; if (valid.test(myForm.cardNum.value)) { alert("This is a Valid MasterCard Card"); } else { alert("This Card Number is Invalid For MasterCard"); } break; case "AmericanExpress": valid = /^3[47][0-9]{13}$/; if (!valid.test(myForm.cardNum.value)) { alert("This is a Valid American Express Card"); return true; } else { alert("This Card Number is Invalid For American Express"); return false; } break; default: valid = /^$/; alert("Card type not found"); return false; } } </script> </head> <body> <h1>Credit Card Validator</h1> <form name="creditCard" onsubmit="return checkCC(this)"> <span class="labels">Card Type:</span> <select name="cardType" size="3"> <option name="visa">Visa</option> <option name="mc">Master Card</option> <option name="amex">American Express</option> </select> <br /> <span class="labels">Card Number:</span> <input name="cardNUm" type="text" size=30 value="" /> <br /> <br /> <input type="submit" value="Death to All" style="background-color:#666666 !important; border:thick groove !important; border-color:#333333 !important" onclick="javascript:return checkCC(this.form)" /> </form> </body> </html> you can find the page he Form Example How do I get this to not happen? I've tried almost every fix I could find that worked for other people none have worked for me. |