JavaScript - Stop Page From Submitting When Refresh Is Clicked
when i click on submit button, all the data in form will be inserted into my db. but when i click on refresh the form will be submitted again .. how can i prevent this?
Similar TutorialsI'm attaching my php test file but this is a JS problem. When I scroll down in the web page and the meta refresh hits, in Windows Safari and IE6/7/8 browsers, the web page re-positions back to the top. In Opera and FF the page refreshes but it stays where it is. Can someone look at my test script and see why it is not working in IE and Win Safari? My goal is to have the web page not re-position to the top on the auto refresh. Thanks... Consider the following piece of code: PHP Code: <form method='post' name='myform'> <input type='submit' name='sub' value='submit 1' /> <input type='submit' name='sub' value='submit 2' /> <a href='javascript:document.myform.submit();'>submit 3</a> </form> <?php echo "You clicked ".$_POST["sub"]; ?> So if you click "submit 1", the output will be You clicked submit 1. And if you click "submit 2", the output will be You clicked submit 2. That's obvious. But ... what do I need to do to pass the key/value pair "sub" = "submit 3" to the server via POST when I click on the hyperlink showing "submit 3" - so that the output is You clicked submit 3 (i.e. so that $_POST contains "submit 3" referenced to index "sub"). I've tried <a href='javascript: a = {"x" : 1}; document.myform.submit(a);'>submit 3</a>, but that doesn't cause a to be passed via POST. HI I have a form that has some fields and inputs . I wrote some javascript code that if there was any problem with entered values , it shows the errors but when the user press submit button , the form submited before it had shown the problems . How can halt it and showing the problems ? TNX I am trying to submit a hidden text area from a WYSIWYG editor. Its submitting the subject line which is a standard text input but its not submitting the text area. I can only think its because there are html tags in the submitted data. Is there a way to compensate for this or will I have to give up trying. I have created a small file where I check if the passwords entered in the code match or not, if they do not match, the button that links to the next webpage should not work(allow them to go to the next wepage). ive tried various websites to help me try and solve this but I just dodont understand what they are doing. I'm very new to programming btw here is some example code: Code: !doctypeHTML <html> <script> //lets just pretend that ive already done all the .getelement by id stuff to get the code things //suppose the person did not write anything in the form, an error will get pushed(alerted basically) if(!form['password'].value) error.push('Missing Password'); <form> <label>Password<br><input type="password" name="password"></label> <label>Confirm Password<br><input type="password" name="confirm"</label> </form> </html> now how would I make the submit button not submit if there are errors? please be as simple as possible, I am new to this! I want to refresh the calculations on a form without submitting the form. I have tried two different JavaScript button codes, and I'm wondering if there is a reason for using one over the other, and if there is something else better for cross-browser use. 1) [ICODE] _doClick('$Refresh', this, '_self') 2) [ICODE] _doClick('$Refresh', this, null, null) Sorry if I missed the answer to this by searching, but I did try. Advice is welcome. I am building a webpage to make my life easier at work. In the page i am simply loading 3 different web pages that i use 100% of the time between each other, and since they are little tools and i can fit them all nicely in one. However, i'm having a problem doing it with the most important one. I've included all 3 pages via iframes, but the third page doesn't work and becomes the topmost every time. This is because this web page uses the Javascript code snipset below in their page: ---------------------------------------- if (top.location != self.location) { top.location = self.location.href; } ---------------------------------------- Please advise me if you have any solution for that. Many thanks, Arch, Hey guys, I'm working on a user website and have got the upload form working and the cropping working, also got the image in my profile, all works great. A few things I need tho and wondering if you could help. I need to stop the form from resubmitting the image when I refresh the upload.php page below upload.php PHP Code: <?php define('INCLUDE_CHECK',true); require 'connect.php'; session_start(); $session_id ='1'; $username = $_SESSION['user']; $upload = $_POST['upload']; $new_name = "small".$username.".jpg"; $path = "uploads/"; ?> <html> <head> <title>My Network</title> </head> <link rel="stylesheet" type="text/css" href="css/imgareaselect-default.css" /> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.imgareaselect.pack.js"></script> <script type="text/javascript"> function getSizes(im,obj) { var x_axis = obj.x1; var x2_axis = obj.x2; var y_axis = obj.y1; var y2_axis = obj.y2; var thumb_width = obj.width; var thumb_height = obj.height; if(thumb_width > 0) { if(confirm("Do you want to save image..!")) { $.ajax({ type:"GET", url:"ajax_image.php?t=ajax&img="+$("#image_name").val()+"&w="+thumb_width+"&h="+thumb_height+"&x1="+x_axis+"&y1="+y_axis, cache:false, success:function(rsponse) { $("#cropimage").hide(); $("#thumbs").html(""); $("#thumbs").html("<img src='uploads/"+rsponse+"' />"); } }); } } else alert("Please select portion..!"); } $(document).ready(function () { $('img#photo').imgAreaSelect({ aspectRatio: '1:1', onSelectEnd: getSizes }); }); </script> <?php $valid_formats = array("jpg", "png", "gif", "bmp"); if(isset($_POST['submit'])) { $name = $_FILES['photoimg']['name']; $size = $_FILES['photoimg']['size']; if(strlen($name)) { list($txt, $ext) = explode(".", $name); if(in_array($ext,$valid_formats) && $size<(1024*1024)) { $actual_image_name = time().substr($txt, 5).".".$ext; $tmp = $_FILES['photoimg']['tmp_name']; if(move_uploaded_file($tmp, $path.$actual_image_name)) { mysql_query("UPDATE user SET profile_image='$actual_image_name' WHERE id='$username'"); $image="<h1>Please drag on the image</h1><img src='uploads/".$actual_image_name."' id=\"photo\" style='max-width:500px' >"; $profile_image="<img src='uploads/".$new_name."' style='max-width:500px' >"; } else echo "failed"; } else echo "Invalid file formats..!"; } else echo "Please select image..!"; } ?> <body> <div style="margin:0 auto; width:600px"> <?php echo $image; ?> <div style="padding:5px; width:600px"> <?php echo $profile_image; ?> </div> <div style="width:600px"> <form id="cropimage" method="post" enctype="multipart/form-data"> Upload your image <input type="file" name="photoimg" id="photoimg" /> <input type="hidden" name="image_name" id="image_name" value="<?php echo($actual_image_name)?>" /> <input type="submit" name="submit" value="Submit" /> </form> </div> </div> </body> </html> ajax_image.php PHP Code: <?php define('INCLUDE_CHECK',true); require 'connect.php'; session_start(); $username = $_SESSION['user']; $upload = $_POST['upload']; $t_width = 100; // Maximum thumbnail width $t_height = 100; // Maximum thumbnail height $new_name = "small".$username.".jpg"; // Thumbnail image name $path = "uploads/"; if(isset($_GET['t']) and $_GET['t'] == "ajax") { extract($_GET); $ratio = ($t_width/$w); $nw = ceil($w * $ratio); $nh = ceil($h * $ratio); $nimg = imagecreatetruecolor($nw,$nh); $im_src = imagecreatefromjpeg($path.$img); imagecopyresampled($nimg,$im_src,0,0,$x1,$y1,$nw,$nh,$w,$h); imagejpeg($nimg,$path.$new_name,90); mysql_query("UPDATE user SET profile_image_small='$new_name' WHERE username='$username'"); echo $new_name."?".time(); exit; } ?> And I also need a live preview of cropping. So when the user is selecting what area of the Large image they want as there final thumb image, they can see the thumb change to that selection at the same time. The thumb is below the uploaded image, and without refreshing, which I cannot yet do because of the form resubmit, you can't see the final image until you go back to your profile. If I didn't make the above clear enough, please tell me. Thanks for any help and suggestions. Hi, I am using Javascript to display options in a form with 2 dropdown lists. However, despite using the rel="nofollow" target='_self', the result opens in a new window. Help would be much appreciated. Code: // JavaScript Document function setOptions(chosen) { var selbox = document.ChronoContact_course_finder.opttwo; selbox.options.length = 0; if (chosen == ' ') { selbox.options[selbox.options.length] = new Option('Choose Option',' '); } if (chosen == '85') { selbox.options[selbox.options.length] = new Option('ITEC Beauty Specialist Diploma','index.php?option=com_content&view=article&id=49&Itemid=68',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('ITEC Professional Makeup','index.php?option=com_content&view=article&id=57&Itemid=76',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Fashion Catwalk & Photographic Makeup Course','index.php?option=com_content&view=article&id=67&Itemid=91',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Bridal Makeup Course','index.php?option=com_content&view=article&id=68&Itemid=92',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Special Effects Makeup','index.php?option=com_content&view=article&id=56&Itemid=77',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Gel Nails Course','index.php?option=com_content&view=article&id=65&Itemid=88',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Acrylic Nails Course','index.php?option=com_content&view=article&id=66&Itemid=89',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Spray Tanning Course','index.php?option=com_content&view=article&id=55&Itemid=73',rel="nofollow" target='_self'); } if (chosen == '69') { selbox.options[selbox.options.length] = new Option('ITEC Holistic Massage Course','index.php?option=com_content&view=article&id=51&Itemid=2',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('ITEC Sports Massage Diploma','index.php?option=com_content&view=article&id=59&Itemid=78',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('Indian Head Massage Course','index.php?option=com_content&view=article&id=60&Itemid=79',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('ITEC Reflexology Diploma','index.php?option=com_content&view=article&id=64&Itemid=87',rel="nofollow" target='_self'); } if (chosen == '80') { selbox.options[selbox.options.length] = new Option('ITEC Teaching Diploma','index.php?option=com_content&view=article&id=61&Itemid=81',rel="nofollow" target='_self'); selbox.options[selbox.options.length] = new Option('FETAC Train The Trainer Level 6','index.php?option=com_content&view=article&id=63&Itemid=86',rel="nofollow" target='_self'); } if (chosen == '83') { selbox.options[selbox.options.length] = new Option('ITEC Sports Massage Diploma','index.php?option=com_content&view=article&id=59&Itemid=90',rel="nofollow" target='_self'); } } And the HTML... Code: <div class="form_item"> <div class="form_element cf_heading"> <h1 class="cf_text">course finder</h1> </div> <div class="cfclear"> </div> </div> <div class="form_item"> <div class="form_element cf_dropdown"> <label class="cf_label" style="width: 200px;">Step 1: Choose type of course</label> <select name="optone" class="cf_inputbox" size="1" onchange="setOptions(document.ChronoContact_course_finder.optone.options[document.ChronoContact_course_finder.optone.selectedIndex].value);"> <option value=" " selected="selected">Choose Option</option> <option value="85">Beauty courses</option> <option value="69">Complimentary courses</option> <option value="80">Teaching courses</option> <option value="83">Fitness courses</option> </select> </div> <div class="cfclear"> </div> </div> <div class="form_item"> <div class="form_element cf_dropdown"> <label class="cf_label" style="width: 200px;">Step 2: Choose a subject</label> <select size="1" name="opttwo" class="cf_inputbox" > <option value=" " selected="selected">Choose Option</option> </select> <!--<input type="button" name="go" value="Value Selected" onclick="window.open(document.ChronoContact_course_finder.opttwo.options[document.ChronoContact_course_finder.opttwo.selectedIndex].value);">--> </div> <div class="cfclear"> </div> </div> <div class="form_item"> <div class="form_element cf_button"> <input type="submit" name="go" value="search" onclick="window.open(document.ChronoContact_course_finder.opttwo.options[document.ChronoContact_course_finder.opttwo.selectedIndex].value);"> </div> <div class="cfclear"> </div> </div> Many thanks, Paul 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... Is there anyway to stop the page 'jumping to the top' when using a link like the below? Code: <a href="#" onClick="arrangeCards();">blah</a> .. I just want it to stay in the same position on the page & not jump to the top of the page every time a link like that is clicked. Cheers! <script language="JavaScript"> function changeColor(cell_id){var state1="#dde6ed"; var state2="#ffc20e"; var cellid = new Array ("id1", "id2", "id3", "id4", "id5", "id6"); for(var i = 0; i < cellid.length; i++){var nav = document.getElementById(cellid[i]); if(cellid == nav.id){nav.style.backgroundColor=state2;} else {nav.style.backgroundColor=state1;}}} </script> Can anyone tell me what is wrong with this script. I put an onClick= changeColor(this);" in my <td> tag to call the script but still not working. hi everyone, Here's part of the codes I got from our website. Right now, when someone wants to register on our website, they have to put into the Captcha after they finish all the other information. If the captcha is empty, there would be an alert; if it's wrong, the page would be refreshed, and there would be another alert, and at the same time, all the information would be lost and they have to fill them again. Now the question is, how can I stop the page refreshing itself? All I need is an alert and then you could retype the captcha without losing the other information. Thank you in advance for your advice! <script type="text/javascript"> function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); } function validateForm() { var okSoFar=true with (document.practitioner_profile) { if (firstname.value=="" && okSoFar) { okSoFar=false alert("Please enter your first name.") firstname.focus() } if (lastname.value=="" && okSoFar) { okSoFar=false alert("Please enter your last name.") lastname.focus() } //some other things here... if (verify_code.value=="" && okSoFar) { okSoFar=false alert("Please enter your security code.") verify_code.focus() } if (okSoFar==true) submit(); } } //here's the submit button in the html code, <div class="practsubmit"> <div class="signupform"><h4>* Security Code:</h4> <p>Please type in what you see in the box below and press submit. Characters are case-sensitive.</p></div> <div class="signupform"><img id="captcha" src="index.php?option=com_egbcaptcha&width=150&height=50&characters=5" /><br /><input id="verify_code" name="verify_code" type="text" /></div> <input type="button" class="button" value="Send" name="B1" ONCLICK="javascript:validateForm()"> <input type="reset" class="button" value="Clear" name="clear"> </div> 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 I have a set of tabs that are set with an href that adds a query string to the url such as "?t=1", meaning the first tab is selected. Technically it works just fine but every time I click a tab it reloads the page and I'm not entirely sure how to stop this. I'm using a jquery plugin to handle the query strings. Here's the plugin. Here's the piece of the code that matters: Code: var url = location.search; var tab = $.query.get('t'); init(tab); function init(tab){ $("div.tab").hide(); //hides all the content boxes related to the tabs $("div#tab"+tab).fadeIn("fast"); //Shows the selected tab's content box setInactive(); //Styles unselected tabs setActive(tab); //Styles selected tab } Any help would be greatly appreciated. Hello there I've been searching and searching but couldn't make this script stop reseting after reloading the page. The scripts counts down some timers every x hours but the problem is that each time the page is reloaded the timer resets. Could anyone help me here how to keep the countdown going even if i reload page? thanks in advance I call the timers with. Example Timer 8: >div... etc id="timeLeft8" Code: <script type="text/javascript"> var events = new Array(); events[1]={name: 'Blood Castle:', startUp: new Array( {hour:0,minute:25}, {hour:2,minute:25}, {hour:4,minute:25}, {hour:6,minute:25}, {hour:8,minute:25}, {hour:10,minute:25}, {hour:12,minute:25}, {hour:14,minute:25}, {hour:16,minute:25}, {hour:18,minute:25}, {hour:20,minute:25}, {hour:22,minute:25} )} events[2]={name: 'Devil Squa ', startUp: new Array( {hour:1,minute:55}, {hour:3,minute:55}, {hour:5,minute:55}, {hour:7,minute:55}, {hour:9,minute:55}, {hour:11,minute:55}, {hour:13,minute:55}, {hour:15,minute:55}, {hour:17,minute:55}, {hour:19,minute:55}, {hour:21,minute:55}, {hour:23,minute:55} )} events[3]={name: 'Chaos Castle:', startUp: new Array( {hour:0,minute:55}, {hour:2,minute:55}, {hour:4,minute:55}, {hour:6,minute:55}, {hour:8,minute:55}, {hour:10,minute:55}, {hour:12,minute:55}, {hour:14,minute:55}, {hour:16,minute:55}, {hour:18,minute:55}, {hour:20,minute:55}, {hour:22,minute:55} )} events[4]={name: 'Red Dragon:', startUp: new Array( {hour:0,minute:0}, {hour:2,minute:0}, {hour:4,minute:0}, {hour:6,minute:0}, {hour:8,minute:0}, {hour:10,minute:0}, {hour:12,minute:0}, {hour:14,minute:0}, {hour:16,minute:0}, {hour:18,minute:0}, {hour:20,minute:0}, {hour:22,minute:0} )} events[5]={name: 'Gold Invasion:', startUp: new Array( {hour:0,minute:0}, {hour:2,minute:0}, {hour:4,minute:0}, {hour:6,minute:0}, {hour:8,minute:0}, {hour:10,minute:0}, {hour:12,minute:0}, {hour:14,minute:0}, {hour:16,minute:0}, {hour:18,minute:0}, {hour:20,minute:0}, {hour:22,minute:0} )} events[6]={name: 'White Wizard:', startUp: new Array( {hour:0,minute:0}, {hour:2,minute:0}, {hour:4,minute:0}, {hour:6,minute:0}, {hour:8,minute:0}, {hour:10,minute:0}, {hour:12,minute:0}, {hour:14,minute:0}, {hour:16,minute:0}, {hour:18,minute:0}, {hour:20,minute:0}, {hour:22,minute:0} )} events[7]={name: 'Blue:', startUp: new Array( {hour:0,minute:40}, {hour:1,minute:40}, {hour:2,minute:40}, {hour:3,minute:40}, {hour:4,minute:40}, {hour:5,minute:40}, {hour:6,minute:40}, {hour:7,minute:40}, {hour:8,minute:40}, {hour:9,minute:40}, {hour:10,minute:40}, {hour:11,minute:40}, {hour:12,minute:40}, {hour:13,minute:40}, {hour:14,minute:40}, {hour:15,minute:40}, {hour:16,minute:40}, {hour:17,minute:40}, {hour:18,minute:40}, {hour:19,minute:40}, {hour:20,minute:40}, {hour:21,minute:40}, {hour:22,minute:40}, {hour:23,minute:40}, {hour:24,minute:40} )} events[7]={name: 'Hide&Seek:', startUp: new Array( {hour:0,minute:42}, {hour:1,minute:22}, {hour:2,minute:32}, {hour:3,minute:42}, {hour:4,minute:52}, {hour:6,minute:02}, {hour:7,minute:12}, {hour:8,minute:22}, {hour:9,minute:32}, {hour:10,minute:42}, {hour:11,minute:52}, {hour:13,minute:02}, {hour:14,minute:12}, {hour:15,minute:22}, {hour:16,minute:32}, {hour:17,minute:42}, {hour:18,minute:52}, {hour:20,minute:02}, {hour:21,minute:12}, {hour:22,minute:22}, {hour:23,minute:32} )} events[8]={name: 'Sky:', startUp: new Array( {hour:1,minute:5}, {hour:4,minute:5}, {hour:7,minute:5}, {hour:10,minute:5}, {hour:13,minute:5}, {hour:16,minute:5}, {hour:19,minute:5}, {hour:23,minute:5} )} events[9]={name: 'Boss Attack:', startUp: new Array( {hour:1,minute:50}, {hour:4,minute:50}, {hour:7,minute:50}, {hour:10,minute:50}, {hour:13,minute:50}, {hour:16,minute:50}, {hour:23,minute:50} )} events[10]={name: 'Happy Hour:', startUp: new Array( {hour:5,minute:5}, {hour:2,minute:5}, {hour:8,minute:5}, {hour:11,minute:5}, {hour:14,minute:5}, {hour:17,minute:5}, {hour:20,minute:5}, {hour:0,minute:5} )} events[11]={name: 'Hit and Up:', startUp: new Array( {hour:0,minute:20}, {hour:2,minute:20}, {hour:5,minute:20}, {hour:8,minute:20}, {hour:11,minute:20}, {hour:14,minute:20}, {hour:20,minute:20} )} events[12]={name: 'Raklion:', startUp: new Array( {hour:0,minute:15}, {hour:3,minute:15}, {hour:6,minute:15}, {hour:9,minute:15}, {hour:12,minute:15}, {hour:15,minute:15}, {hour:18,minute:15}, {hour:21,minute:15} )} events[13]={name: 'Moss:', startUp: new Array( {hour:3,minute:35}, {hour:7,minute:35}, {hour:11,minute:35}, {hour:15,minute:35}, {hour:19,minute:35}, {hour:23,minute:35} )} events[14]={name: 'Illusion Temple:', startUp: new Array( {hour:0,minute:25}, {hour:1,minute:25}, {hour:2,minute:25}, {hour:3,minute:25}, {hour:4,minute:25}, {hour:5,minute:25}, {hour:6,minute:25}, {hour:7,minute:25}, {hour:8,minute:25}, {hour:9,minute:25}, {hour:10,minute:25}, {hour:11,minute:25}, {hour:12,minute:25}, {hour:13,minute:25}, {hour:14,minute:25}, {hour:15,minute:25}, {hour:16,minute:25}, {hour:17,minute:25}, {hour:18,minute:25}, {hour:19,minute:25}, {hour:20,minute:25}, {hour:21,minute:25}, {hour:22,minute:25}, {hour:23,minute:25}, {hour:24,minute:25} )} events[15]={name: 'Castle Deep:', startUp: new Array( {hour:1,minute:25}, {hour:7,minute:25}, {hour:13,minute:25}, {hour:19,minute:25} )} events[16]={name: 'CryWolf:', startUp: new Array( {hour:1,minute:45}, {hour:4,minute:45}, {hour:7,minute:45}, {hour:10,minute:45}, {hour:13,minute:45}, {hour:16,minute:20}, {hour:19,minute:45}, {hour:22,minute:45} )} var curTime=1336998502 var dateTime=1336953600 function timeLeft(i){ for(j in events[i].startUp){ tmp=events[i].startUp[j].hour*3600+events[i].startUp[j].minute*60 if(dateTime+tmp>curTime){ return dateTime+tmp-curTime; } } tmp=events[i].startUp[0].hour*3600+events[i].startUp[0].minute*60 return dateTime+86400+tmp-curTime; } function getFormatedLeftTime($seconds){ $second = $seconds % 60; $minutes = parseInt(($seconds / 60) % 60); $hour = parseInt(($seconds / 3600) % 24); $days = parseInt($seconds / (24 * 3600)); $ret = ''; if ($days > 0) if ($days == 1) $ret += '1 day '; else $ret += $days + ' days '; if ($hour > 0){ if ($hour < 10) $hour = '0' + $hour; $ret += $hour + ':'; }else if ($days > 0) $ret += '00:'; if($minutes < 10) $minutes = '0' + $minutes; $ret += $minutes + ':'; if ($second < 10) $second = '0' + $second; $ret += $second; return $ret; } function updateTimes(){ curTime++; for (i in events){ document.getElementById("timeLeft"+i).innerHTML=getFormatedLeftTime(timeLeft(i)); } } for(i in events) document.getElementById("eventList").innerHTML+="<div style='float:right; color: #FFFF00;' id='timeLeft"+i+"'>"+getFormatedLeftTime(timeLeft(i))+"</div><div style=\"color: #00FFFF;\"><strong>"+events[i].name+"</strong></div>"; setInterval("updateTimes()", 1000); </script> Probably a stupid noob question, is there any way I can stop document.write from outputting info to a new page I would prefer to have it shown in a textarea. Info from an array that is suppose to display in a text area when button is clicked and when another button is clicked it is suppose to show some other info. But what happens is the first info displays in textarea for a few seconds and then the second info is displayed but on a new page and not the textarea where I want it to go I have marked code within the code // I want this specific code to be displayed second but I know its in the wrong spot. Here is the code [CODE] function show() { var myArray = new Array(); myArray[0] = document.getElementById('fullname').value; ' myArray[1] = document.getElementById('address').value; myArray[2] = document.getElementById('phone').value; myArray[3] = document.getElementById('email').value; //Code I want to display second in the textarea //var string = myArray.join("\n") //document.getElementById('textarea').value = string; document.writeln('Thank you for registering,' + ' ' + myArray[0] + '. Your membership will be confirmed by E-mail to ' + myArray[2] + "<br>"); document.writeln('Registration Details:') document.writeln("<br>") for (var i=0; i<myArray.length; i++) { document.write(myArray[i] + "<br>"); } } [\CODE] Thanks in advance 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 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 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) |