JavaScript - Need Help With Javascript Code (forms And Cookies)
I am trying to make it when a user comes to a site, if they have been there before an alert box will open saying "Welcome firstname, lastname, and email address".
Right now I can get the code to work to show a first name, but when I try to get it to also show the last name and email I get an error or something like "Welcome NaN NaN, NaN". Here is the code I have right now. Code: function confirmSubmission() { var confirmed = validateData(); return confirmed; }//confirmSubmission function validateData() { if (document.forms[0].elements[1].value == "") { alert("You must enter a first name."); document.forms[0].elements[1].focus(); return false; }//blank first name if (document.forms[0].elements[2].value == "") { alert("You must enter a last name."); document.forms[0].elements[2].focus(); return false; }//blank last name if (document.forms[0].elements[3].value == "") { alert("You must enter an address."); document.forms[0].elements[3].focus(); return false; }//blank address if (document.forms[0].elements[4].value == "") { alert("You must enter a city."); document.forms[0].elements[4].focus(); return false; }//blank city if (document.forms[0].elements[5].value == "") { alert("You must enter a state."); document.forms[0].elements[5].focus(); return false; }//blank state if (document.forms[0].elements[6].value == "") { alert("You must enter a zipcode."); document.forms[0].elements[6].focus(); return false; } else { if (/...../.test(document.forms[0].elements[6].value) == false) { alert("You must enter a valid zipcode."); document.forms[0].elements[6].focus(); return false; } }//blank zip if (document.forms[0].elements[7].value == "") { alert("You must enter an e-mail address."); document.forms[0].elements[7].focus(); return false; } else { if (/@/.test(document.forms[0].elements[7].value) == false || (document.forms[0].elements[7].value).indexOf(".", (document.forms[0].elements[7].value).indexOf("@")) == -1) { alert("You must enter a valid e-mail address."); document.forms[0].elements[7].focus(); return false; } }//blank email if (document.forms[0].elements[8].value == "" || document.forms[0].elements[9].value == "" || document.forms[0].elements[10].value == "") { alert("You must enter a telephone number."); document.forms[0].elements[8].focus(); return false; } else { if (/.../.test(document.forms[0].elements[8].value) == false) { alert("You must enter a valid area code."); document.forms[0].elements[8].focus; return false; }//area code else if (/.../.test(document.forms[0].elements[9].value) == false) { alert("You must enter a valid telephone exchange."); document.forms[0].elements[9].focus; return false; }//NNX else if (/..../.test(document.forms[0].elements[10].value) == false) { alert("Your number must be four characters."); document.forms[0].elements[10].focus; return false; }//number }//blank telephone setCookie('username', document.forms[0].elements[1].value, 2); return true; }//validateData function setCookie(c_name, value, expiredays) { var expDate=new Date(); expDate.setDate(expDate.getDate() + expiredays); document.cookie=c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires=" + expDate.toUTCString()); And on another page I have: Code: function checkCookie() { username = getCookie('username'); if (username != null && username != "") alert('Welcome back, ' + username + '!'); }//checkCookie function getCookie(c_name) { if (document.cookie.length > 0) { c_start = document.cookie.indexOf(c_name + "="); if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start, c_end)); } } return ""; } Any help would be appreciated. Similar TutorialsHello everyone! I am having really tough time learning JavaScript Cookies! Can somebody explain me how to use them? "Please do not provide any external links! It is a request!" Any type of basic lesson/advice/suggestion will be quite helpful to me. Thanks! hello to everyone i need a way to create a cookie based on user selection from a dropdown list and a radio button set . from the drop down list i control var city (1,2,3...) and from the radio buttons dow(f,s) , cdate(a,b,c,...) , ctime (a,b,c,...) it is a clock format and i want in the first page when the user select's the format that he wants it will remain in every page until he leaves the site Thankz Hi I am very new to JavaScript. Please help me to get my code working. I want to store user preferences with cookie. With two buttons, to increase and decrease the font size. The following is my code to create cookies and check cookies. But I am lost with the buttons and other coding. Please help me.. 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>Untitled Document</title> <script type="text/javascript"> 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; } function checkCookie(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 fsize(size,unit,id){ var vfontsize = document.getElementById("text1"); if(vfontsize){ vfontsize.style.fontSize = size + unit; createCookie("textsizestyle", textsize, 365); } } var cookie = readCookie("textsizestyle"); textsize = cookie ? cookie : 10; fsize(textsize,'px','content'); </script> </head> <body> <label> Change this font according to button click </label><br /> <input type="button" id="text1" value=" small" onclick="fsize()"/> <input type="button" id="text2" value="big" onclick="fsize()"/> </body> </html> Thanks Hi all, I've been trying to set, get and delete js cookies for a while now, although they seem to set (from what I can tell) I can't seem to do what else I need with them. This is what I'm trying to do: Function1 - setCookie (sets a cookie called 'saveAndExit' - that's it, no expiry date) Function2 - useCookie (checks to see if a cookie called 'saveAndExit' exists and if it does alert("COOKIE WORKS") and then deletes the cookie If it doesn't exist alert("cookie does not exists") Could anyone assist with this? It's been driving me insane for days! Thanks. hy guys I have this Ad Script script: <HEAD> section Code: <style type="text/css"> <!-- #sponsorAdDiv {position:absolute; height:1; width:1px; top:0; left:0;} --> </style> <script type="text/javascript"> adTime=10; // seconds ad reminder is shown chanceAd=1; // ad will be shown 1 in X times (put 1 for everytime) var ns=(document.layers); var ie=(document.all); var w3=(document.getElementById && !ie); var calunit=ns? "" : "px" adCount=0; function initAd(){ if(!ns && !ie && !w3) return; if(ie) adDiv=eval('document.all.sponsorAdDiv.style'); else if(ns) adDiv=eval('document.layers["sponsorAdDiv"]'); else if(w3) adDiv=eval('document.getElementById("sponsorAdDiv").style'); randAd=Math.ceil(Math.random()*chanceAd); if (ie||w3) adDiv.visibility="visible"; else adDiv.visibility ="show"; if(randAd==1) showAd(); } function showAd(){ if(adCount<adTime*10){adCount+=1; if (ie){documentWidth =truebody().offsetWidth/2+truebody().scrollLeft-20; documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;} else if (ns){documentWidth=window.innerWidth/2+window.pageXOffset-20; documentHeight=window.innerHeight/2+window.pageYOffset-20;} else if (w3){documentWidth=self.innerWidth/2+window.pageXOffset-20; documentHeight=self.innerHeight/2+window.pageYOffset-20;} adDiv.left=documentWidth-200+calunit;adDiv.top =documentHeight-200+calunit; setTimeout("showAd()",100);}else closeAd(); } function closeAd(){ if (ie||w3) adDiv.display="none"; else adDiv.visibility ="hide"; } function truebody(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } onload=initAd; //End--> </script> right above the </BODY> Code: <div id="sponsorAdDiv" style="visibility:hidden"> <table width="450px" height="350px" bgcolor="#008000"><tr><td> <table width="445px" height="345px" bgcolor="#F0FFF0"><tr><td align="center" valign="middle"> <!--*****EDIT THIS MESSAGE*****--> <!--*****EDIT THE ABOVE MESSAGE*****--> </td></tr></table></td></tr></table> </div> And i trying to find a way to show a div with text and images just once per day using cookies....i like something like this http://javascript.internet.com/cooki...opup-once.html but not with popup. Hi I am working on a .net basket where I save the info for the products in the basket etc in a cookie. Now I have an html button on the basket page where I want to be able to delete the product (Cookie). I am using Code: <script type="text/javascript"> function delete_cookie ( cookie_name ) { expires = Now(); document.cookie = cookie_Name+"= ;expires="+expires.toGMTString(); } </script>But I get an error that says the cookie is not delcared? But it does exist because I retrive the name of the cookie when looping through the cookie list. What am I doing wrong here? Hi... is there a way to create iframes using cookies and javascript ? What i need to do is to have a way to create a cookie on page one, and use the info on page two to create the iframe. Users will see a list of "external links", once they click on a link, they will be redirected to a page that will generate a iframe of the chosen link. My guess is that if there is a way, it must need to use cookies to store the info (url) to get used by the script that will create the iframe on the page that will be used to show all iframes. Any ideas or help with this will be apriciated. Sorry for my poor english. I'm more of an actionscript person but got roped into an html/javascript job. What I need to do, and it shouldn't be that difficult is this: page1.html - there is a yellow button and a red button - if the user clicks on the yellow button I want to set a cookie with the value "yel" then load the next page - if they click the red button set that cookie with the value "red" page2.html - 'onload' i want to read that cookie and load up the main image to match, something like this maybe?... document.mainimage.src='img/main_' + variable + '.png' so that the path would be for example 'img/main_red.png' Any help please? Preferably javascript only and as simple as possible. If you think this would be easier sending that variable in the URL instead of as a cookie please explain. I'm having a very hard time searching for tutorials that are any good and that do exactly this kind of thing. Hello guys! I have a jquery fancybox that pop's up on exit (using onbeforeunload), now i want it to show only once so i tried doing it with cookies but i just can get it to work. this is my script so far hope you can help me with this, Thanks! Code: <script type="text/javascript"> function PopIt() { if (document.cookie.length == 0) { var exdate=new Date(); exdate.setDate(exdate.getDate()+7); document.cookie="cook=yes" + ";expires="+exdate.toUTCString(); $("a#trigger").trigger('click'); window.onbeforeunload = UnPopIt; return "Before you leave:\nPlease take a few seconds to answer 2 questions\nso we can better assist you and others in the future. \nThanks!"; } } function UnPopIt() { /* nothing to return */ } $(document).ready(function() { window.onbeforeunload = PopIt; $("a#trigger").fancybox({ 'hideOnContentClick': false, 'showCloseButton': true }); $("a[id!=trigger]").click(function(){ window.onbeforeunload = UnPopIt; }); }); </script> I've looked on several websites and several threads here regarding writing and reading cookies with javascript, and I just can't seem to get it to work. All I want is a simple text box with 2 buttons: Save and Recall. Text entered into box is saved to a cookie when "Save" is pressed, and at a later date when "Recall" is pressed the saved text will show up in the box. Can you help please? I'm running into a bit of problems trying to use some JS cookies. I have 2 values I want stored and have created the following set cookie function
Code: setCookie(Name, amountCorrect, totalAmountCorrect, max-age) { document.cookie = "averageScore" + quizAverageIncrement + totalCorrect +"; max-age=" + 1000 * 60 * 60 * 24 * 30 +"; path=/; } Now I want to read the cookie and use the values from the two variables "averageScore" and "quizAverageIncrement" I'm not sure exactly how to be able to use the values of those two variables since they have been concatenated into a string when the cookie is made (I think). So I would like to start with Code: function getCookie(averageScore) { // if cookie is blank on first iteration do nothing else retrieve values I need. \n if (document.cookie.length > 0 Thats all I have please point me in the right direction to retrieve these values and use them in my JS elsewhere. Hi all, I am having some problems with the below multiple image upload script. Code: <script type="text/javascript"> set_cookie ( "uid", "14" ); </script> <script type="text/javascript"> $(function(){ $('#swfupload-control').swfupload({ upload_url: "upload-file.php", file_post_name: 'uploadfile', file_size_limit : "10240", file_types : "*.jpg;*.png;*.gif", file_types_description : "Image files", file_upload_limit : 100, flash_url : "jquery/swfupload/swfupload.swf", button_image_url : 'jquery/swfupload/wdp_buttons_upload_114x29.png', button_width : 114, button_height : 29, button_placeholder : $('#button')[0], debug: false }) .bind('fileQueued', function(event, file){ var listitem='<li id="'+file.id+'" >'+ 'File: <em>'+file.name+'</em> ('+Math.round(file.size/1024)+' KB) <span class="progressvalue" ></span>'+ '<div class="progressbar" ><div class="progress" ></div></div>'+ '<p class="status" >Pending</p>'+ '<span class="cancel" > </span>'+ '</li>'; $('#log').append(listitem); $('li#'+file.id+' .cancel').bind('click', function(){ var swfu = $.swfupload.getInstance('#swfupload-control'); swfu.cancelUpload(file.id); $('li#'+file.id).slideUp('fast'); }); // start the upload since it's queued $(this).swfupload('startUpload'); }) .bind('fileQueueError', function(event, file, errorCode, message){ alert('Size of the file '+file.name+' is greater than limit'); }) .bind('fileDialogComplete', function(event, numFilesSelected, numFilesQueued){ $('#queuestatus').text('Files Selected: '+numFilesSelected+' / Queued Files: '+numFilesQueued); }) .bind('uploadStart', function(event, file){ $('#log li#'+file.id).find('p.status').text('Uploading...'); $('#log li#'+file.id).find('span.progressvalue').text('0%'); $('#log li#'+file.id).find('span.cancel').hide(); }) .bind('uploadProgress', function(event, file, bytesLoaded){ //Show Progress var percentage=Math.round((bytesLoaded/file.size)*100); $('#log li#'+file.id).find('div.progress').css('width', percentage+'%'); $('#log li#'+file.id).find('span.progressvalue').text(percentage+'%'); }) .bind('uploadSuccess', function(event, file, serverData){ var item=$('#log li#'+file.id); item.find('div.progress').css('width', '100%'); item.find('span.progressvalue').text('100%'); var pathtofile='<img src="uploads/'+file.name+'" height="120px" width="120px"></img>'; item.addClass('success').find('p.status').html(pathtofile); }) .bind('uploadComplete', function(event, file){ // upload has completed, try the next one in the queue $(this).swfupload('startUpload'); }) }); </script> Process Page (upload-file.php) Code: <script type="text/javascript"> function get_cookie ( uid ) { var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' ); if ( results ) return ( unescape ( results[2] ) ); else return null; } </script> <?php include('includes/config.php'); $uploaddir = 'uploads/'; $file = $uploaddir . basename($_FILES['uploadfile']['name']); $size=$_FILES['uploadfile']['size']; if($size>10485760) { echo "error file size > 10 MB"; unlink($_FILES['uploadfile']['tmp_name']); exit; } if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { $uploadedfiles = ($_FILES); $files = $uploadedfiles; foreach($files as $value) $a_id = $_COOKIE['a_id']; $u_id = '<script type="text/javascript">var x = get_cookie ( "uid" );</script>'; { $insert = "INSERT INTO images (a_id, u_id) VALUES ('$a_id', '$u_id')"; mysql_query($insert) or die(mysql_error()); } echo "success"; } else { echo "error ".$_FILES['uploadfile']['error']." --- ".$_FILES['uploadfile']['tmp_name']." %%% ".$file."($size)"; } ?> Basically the problem I am having that when the row is entered into the database, it always inputs a 0 for a_id and u_id, I have tried this with php cookies, php sessions and now I am trying with javascript cookies. Why wont the included file read the cookies? Is their anyway to pass data into this script? I believe that Code: upload_url: "upload-file.php", is the issue, I cant seem to parse any data into this file? Any help would be greatly appreciated, this is driving me nuts! Hello, Im pretty new at JavaScript still, and I am trying to add cookies to a page of my website, so that what is entered into form fields, is retained for future visits. Below is my code, and I am scratching my head as to why it is not working for me! I have viewed a few different cookie tutorials, and so far trying to shape them around what I am seeking, is leading me to my broken code. Javascript: Code: var today = new Date(); var expiry = new Date(today.getTime() + 100 * 24 * 3600 * 1000); function setCookie(name, value) { document.cookie=name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString(); } function storeValues(form) { setCookie("name", contact.name.value); setCookie("email", contact.email.value); setCookie("phone", contact.phone.value); return true; } if(name = getCookie("name")) document.contact.name.value = name; if(email = getCookie("email")) document.contact.email.value = email; if(phone =getCookie("phone")) document.contact.phone.value = phone; HTML for the Form Code: <form action="mailto:ksim@dbk.com" method="POST" name="contact" onsubmit="return validateForm();" > <ul> <li> <strong>Name<font color="#5fb81e">*</font></strong> <div><input type="text" size="25" name="name" /></div> </li> <li> <strong>E-mail Address<font color="#5fb81e">*</font></strong> <div><input type="text" size="25" name="email" /></div> </li> <li> <strong>Phone Number<font color="#5fb81e">*</font></strong> <div><input type="text" size="25" name="phone" /></div> </li> <li> <strong>Prefered Type of Contact?<font color="#5fb81e">*</font></strong> <div><input type="radio" name="contact" value="email" id="contactem" /> E-mail<br /> <input type="radio" name="contact" value="phone" id="contactph" /> Phone</div> </li> <li> <strong>Reason For Contact?</strong> <div><input type="checkbox" name="reason" value="showinfo" />Show Information<br /> <input type="checkbox" name="reason" value="groupinfo" />Group Information<br /> <input type="checkbox" name="reason" value="collab" /> Collaboration<br /> <input type="checkbox" name="reason" value="misc" />Misc </div> </li> <li> <strong>What Are You Contacting About?<font color="#5fb81e">*</font></strong> <div><textarea name="message" rows="7" cols="28"></textarea></div> </li> <li> <strong></strong> <div><input type="button" value="Save" conclick="setCookie();"/><button type="reset">Reset</button><button type="submit">Submit</button> </div> </li> </ul> If anyone has some tips to point me in the right direction, and let me see the error of my ways (pun totally intended) I would appreciate it. Hi! I'm trying to make a multiple choice quiz using javascript. I downloaded codes from http://www.javascriptkit.com/script/cut180.shtml But when I used it nothing comes up on the results (number of correct answer, number of wrong answer and percentage) as well as the solution box is empty. I tried it on Google Chrome and it says "Your browser does not accept cookies. Please adjust your settings." So I tried it in Safari because that's what we use in school and it doesn't work. The results and solution box is empty. I am guessing that problem is with cookies? Please help me. Here are my codes: - Quiz //Enter total number of questions: var totalquestions=10 //Enter the solutions corresponding to each question: var correctchoices=new Array() correctchoices[1]='a' //question 1 solution correctchoices[2]='d' //question 2 solution, and so on. correctchoices[3]='b' correctchoices[4]='b' correctchoices[5]='c' correctchoices[6]='b' correctchoices[7]='a' correctchoices[8]='c' correctchoices[9]='d' correctchoices[10]='b' /////Don't edit beyond here////////////////////////// function gradeit(){ var incorrect=null for (q=1;q<=totalquestions;q++){ var thequestion=eval("document.myquiz.question"+q) for (c=0;c<thequestion.length;c++){ if (thequestion[c].checked==true) actualchoices[q]=thequestion[c].value } if (actualchoices[q]!=correctchoices[q]){ //process an incorrect choice if (incorrect==null) incorrect=q else incorrect+="/"+q } } if (incorrect==null) incorrect="a/b" document.cookie='q='+incorrect if (document.cookie=='') alert("Your browser does not accept cookies. Please adjust your browser settings.") else window.location="results.htm" } function showsolution(){ var win2=window.open("","win2","width=200,height=350, scrollbars") win2.focus() win2.document.open() win2.document.write('<title>Solution</title>') win2.document.write('<body bgcolor="#FFFFFF">') win2.document.write('<center><h3>Solution to Quiz</h3></center>') win2.document.write('<center><font face="Arial">') for (i=1;i<=totalquestions;i++){ for (temp=0;temp<incorrect.length;temp++){ if (i==incorrect[temp]) wrong=1 } if (wrong==1){ win2.document.write("Question "+i+"="+correctchoices[i].fontcolor("red")+"<br>") wrong=0 } else win2.document.write("Question "+i+"="+correctchoices[i]+"<br>") } win2.document.write('</center></font>') win2.document.close() } ______________________________________________________________ For Results <html> <head> <title>Instant Quiz Results</title> </head> <body bgcolor="#FFFFFF"> <p align="center"><strong><font face="Arial"> <script src="quizconfig.js"> </script>Quiz Results Summary</font></strong></p> <div align="center"><center> <table border="0" cellspacing="0" cellpadding="0"> <tr> <td width="100%"><form method="POST" name="result"><table border="0" width="100%" cellpadding="0" height="116"> <tr> <td height="25" bgcolor="#D3FFA8"><strong><font face="Arial">Number Of Correct Questions:</font></strong></td> <td height="25"><p><input type="text" name="p" size="24"></td> </tr> <tr> <td height="17" bgcolor="#D3FFA8"><strong><font face="Arial">Wrong Questions:</font></strong></td> <td height="17"><p><textarea name="T2" rows="3" cols="24" wrap="virtual"></textarea></td> </tr> <tr> <td height="25" bgcolor="#D3FFA8"><strong><font face="Arial">Grade Percentage:</font></strong></td> <td height="25"><input type="text" name="q" size="8"></td> </tr> </table> </form> </td> </tr> </table> </center></div> <form method="POST"><div align="center"><center><p> <script> var wrong=0 for (e=0;e<=2;e++) document.result[e].value="" var results=document.cookie.split(";") for (n=0;n<=results.length-1;n++){ if (results[n].charAt(1)=='q') parse=n } var incorrect=results[parse].split("=") incorrect=incorrect[1].split("/") if (incorrect[incorrect.length-1]=='b') incorrect="" document.result[0].value=totalquestions-incorrect.length+" out of "+totalquestions document.result[2].value=(totalquestions-incorrect.length)/totalquestions*100+"%" for (temp=0;temp<incorrect.length;temp++) document.result[1].value+=incorrect[temp]+", " </script> <input type="button" value="Retake Quiz" name="B1" onClick="history.go(-1)"> <input type="button" value="Show Solution" name="B2" onClick="showsolution()"></p> </center></div> </form> </body> </html> Please help me. I've been trying to find out what is wrong with my codes for a week. Thanks in advance! I have a document that contains four forms. I want to run a function only in the form the user is currently in. I keep getting the "document.my_form_name is undefined" error. I've tried all sorts of ways of doing this but can't find a solution. Here's a snippet of the HTML: Code: <form id="my_form_1" name="my_form_1" action="some action" method="POST"> // in here I call the function onchange_display_sel_droplist and // pass through the name of the form </form> <form id="my_form_2" name="my_form_2" action="some action" method="POST"> bla bla </form> Here's the part of the function in question: Code: function onchange_display_sel_droplist(my_value, my_object, my_text_obj, my_form_name) { // create array with all the divs found var arr = new Array(); arr = document.my_form_name.getElementsByTagName( "div" ); // loop through array for(var i=0; i < arr.length; i++) { var tagId = document.my_form_name.getElementsByTagName( "div" ).item(i).id; // find all the divs with ID "my_selected_div__" if ( tagId.indexOf("add_selected_div__") > -1 ) { // hide all document.my_form_name.getElementById(tagId).style.display = "none"; } } // display selected object (droplist) document.my_form_name.getElementById(my_object).style.display = ""; } Hello. I have a youtube video that autoplays everytime one opens the webpage containing the video. The only extra parameter that causes the video to autoplay is having the following added at the end of the embed src link: "&autoplay=1" If that is not present or if a zero is present in place of the 1, the video does not autoplay. I would like the video to play only once per session. If one is visiting the webpage a second time, the parameter above should not be present or the 1 should be a zero. I am modifying attempting to modify this code: http://www.javascriptkit.com/script/...2/postit.shtml and I am able to get differnt urls to print on screen depending if it's a first visit or not. Problem 1: I cannot however get this to work in Google Chrome. Problem 2: When I attempt to get the url to be printed inside the embed src [/B]link, which is inside the object tag, the javascript either gets printed or that portion is ignored. I don't know if this is because of the quotations and the way I am handling them or if because javascript cannot be inserted inside an object tag. Here is the code: Code: <html> <body> <br><br> <script type="text/javascript"> //Post-it only once per browser session? (0=no, 1=yes) //Specifying 0 will cause postit to display every time page is loaded var once_per_browser=1 ///No need to edit beyond here/// /* var ns4=document.layers var ie4=document.all var ns6=document.getElementById&&!document.all if (ns4) crossobj=document.layers.postit else if (ie4||ns6) crossobj=ns6? document.getElementById("postit") : document.all.postit function closeit(){ if (ie4||ns6) crossobj.style.visibility="hidden" else if (ns4) crossobj.visibility="hide" } */ var url = "\"http://www.youtube.com/blah/version=3&hl=en_US&fs=1\""; function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) if (offset != -1) { // if cookie exists offset += search.length // set index of beginning of value end = document.cookie.indexOf(";", offset); // set index of end of cookie value if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; } function showornot(){ if (get_cookie('postdisplay')==''){ showit() document.cookie="postdisplay=yes" } } function showit(){ url = "\"http://www.youtube.com/blah/version=3&hl=en_US&fs=1&autoplay=1\""; /*if (ie4||ns6) crossobj.style.visibility="visible" else if (ns4) crossobj.visibility="show" */ } if (once_per_browser) showornot() else showit() </script> <b>Outside the Object Tag:</b> <br> <script type="text/javascript">document.write(url);</script> <br><br> <b>In the Object Tag</b> <br><br> <object width="570" height="250"><param name="movie" value="http://www.youtube.com/blah?version=3&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src=<script type="text/javascript">document.write(url);</script> type="application/x-shockwave-flash" width="570" height="250" allowscriptaccess="always" allowfullscreen="true"></embed></object> </body> </html> I'm having a total brain fart as to why this is happening. I just transferred my company's website from aplus.net servers to a linux based server on GoDaddy. My company's "shop" page has a drop down menu which should automatically re-direct you to a different page (on a different website where our shopping cart is hosted) when the option is selected. For some reason, after the switch to a different host, the option tags are no longer re-directing to the proper pages. Instead, they just tack on the value URL onto the existing URL and i just go in circles. javascript: <script language="JavaScript" type="/text/javascript"> function nav() { var w = document.myform.mylist.selectedindex.html; var url_add = document.myform.mylist.options[w].value; window.location.href = url_add; } </script> HTML for options form: <FORM NAME="myform"> <SELECT NAME="mylist" onChange="nav()"> <OPTION VALUE="http://bedvoyage.com/shop">Select Your Product <OPTION VALUE="http://bedvoyage.myshopify.com/products/twin-sheet-set">Sheet Set - Twin - $139.00 <OPTION VALUE="http://bedvoyage.myshopify.com/products/double-sheet-set">Sheet Set - Double - $159.00 <OPTION VALUE="http://bedvoyage.myshopify.com/products/queen-sheet-set">Sheet Set - Queen - $179.00 <OPTION VALUE="http://bedvoyage.myshopify.com/products/king-sheet-set">Sheet Set - King - $199.00 <OPTION VALUE="http://bedvoyage.myshopify.com/products/twin-pillow-case">Pillow Case - Twin - $20.00 <OPTION VALUE="http://bedvoyage.myshopify.com/products/double-pillow-case">Pillow Case Set - Double - $40.00 <OPTION VALUE="http://bedvoyage.myshopify.com/products/queen-pillow-case">Pillow Case Set - Queen - $42.00 <OPTION VALUE="http://bedvoyage.myshopify.com/products/king-pillow-case">Pillow Case Set - King - $45.00 <option value="http://bedvoyage.myshopify.com/products/zippered-travel-pillow-case">Zippered Travel Pillow Case - $19.00 <!-- <OPTION VALUE="http://bedvoyage.myshopify.com/produ...uot;>Travel Blanket - $39.00 --> </SELECT> </FORM> Is there an option on godaddy that i'm just missing out on that i'm too ignorant to notice? Thanks in advance. When I click Vacant after 5 and it goes to occupied. How would I make it come back to vacant when clicked again? Code: <html> <head> <script type="text/javascript"> function fillForm() { if (counter > 10){ } } </script> <script type="text/javascript"> function StartCounting(){ setInterval("DoCounting()", 1000) } var Counter = 0; function DoCounting(){ var obj = document.getElementById('countingtext'); obj.innerHTML = '' + Counter; Counter++; if( Counter > 5) { var obj1 = document.getElementById("closed").value = "Open"; var space1 = document.getElementById("space1") space1.onclick = linkClick; } } function linkClick(){ space1 = document.getElementById("space1").value = "Occupied"; } </script> </head> <body onload= "StartCounting()"> Open at 5: <span id="countingtext"></span> </body> </html> <div style="margin-right:3mm; " > <form action="#" method="post" id="theForm" > <input size="10" id="closed" value="Closed" style="text-align:center;" /> <script type="text/javascript"> </script> <input type='button' id="space1" name='s"+ i+"' value='Vacant' onclick='readSpace(s"+ i+")' style='width:15mm;' /></td> </form> </div> I cannot get the result right. I write area and phone by numbers but it still gives me error Code: function validate_text(field,alerttext) { with(field) { var re = /[a-zA-Z]/g; if(re.test(field)) { return true;}else{alert(alerttext);return false;} } } function validate_number(field,alerttext){ with(field) { var re = /[0-9]/g; if(re.test(field)) { return true;}else{alert(alerttext);return false;} } } function validateForm(thisForm){ with(thisForm) { if(validate_number(area,"wrong area code") == false) { area.focus();return false; } if(validate_number(phone,"wrong phone") == false) { phone.focus();return false; } if(validate_text(name_surname,"wrong name") == false) { name_surname.focus();return false; } } } Code: ...<b>Name Surname :</b><input style="margin-left:10px;" type="text" name="name_surname"/> <br /><br /> <b>phone :</b><input type="text" style="margin-left:19px;" maxlength="4" size="4" name="area" /> -<input type="text" style="margin-left:5px;" maxlength="7" size="10" name="phone" /><br /><br />.... Hi, I am very new to Javascript and am having some difficulties with implementing two forms on the same page. The page in question is http://www.devoteddomains.com/contac...ed-domains.asp. The form at the top appears on every page and works on all of the other pages except this one. When you try to complete the form it validates the second form on the page. The code for the top form can be found he http://www.devoteddomains.com/web-de...vices-cta.html (it is an include file). The two scripts that I am using are as follows: Top Form: http://www.devoteddomains.com/scripts/scripts.js Contact Page Form: http://www.devoteddomains.com/scripts2/scripts.js Can someone please help! Cheers, Peter |