JavaScript - Simple Function To Redirect User
Hi, I rarely use javascript so pardon my newbieness.
I'm trying to create a function that is triggered by a <select> onchange event. It's supposed to save the newly selected value in a variable, then refer the user to a link location + variable. This is what I tried: Code: <script type="text/javascript"> function categoryRef() { var a = this.options[this.selectedIndex].value; document.location = 'recommend.php?cat=' + a; } </script> <select name="category" onChange="categoryRef()"> <?php $getCategoryQuery = "SELECT category FROM categories ORDER BY category"; $ConnectQuery = $database->query($getCategoryQuery); while($category = mysql_fetch_array($ConnectQuery)){ if($getCategory == $category['category']){ echo "<option selected='selected'>" . $category['category'] . "</option>"; } else{ echo "<option>" . $category['category'] . "</option>"; } } ?> </select> When I try this and change option nothing happens. Any pointers? Similar TutorialsI am trying to use a user defined function and text area for a project, but nothing is showing up in the text area when i click the button. Code: <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> <script type="text/javascript"> function Greet() // Assumes: firstNameBox and companyName contain names // Results: writes a message with those names in messageArea { firstName = document.getElementById("firstNameBox").value; companyName = document.getElementById("companyNameBox").value; message = "To whom it may concern, my name is " + firstName + ", I am very interested in the job opening at, " + compnayName + ". I feel that I would greatly contribute to " + companyName + " success. I feel I fit the requirements needed to become an employee at " + companyName + ". I look forward to hearing from you."; document.getElementById("messageArea").value = message; } </script> </head> <body> <p> Enter your first name: <input type="text" id="firstNameBox" size="15" /> <br /> Enter the Company name: <input type="text" id="companyNameBox" size="15" /> </p> <p> <input type="button" value="Click for Greeting" onclick="Greet();" /> </p> <p> <textarea id="messageArea" rows="4" cols="40"></textarea> </p> </body> In my onbeforeunload event, it asked the user whether they want to leave the page or stay on it. When they click "stay on page", I want it to then redirect them to another webpage in the same window. Is there a way to do this, without just showing/hiding divs? Can I override the function? I'm currently trying to do it this way(as seen below) but now the dialog box is not showing up at all. It was working before Any ideas as to what I'm doing wrong, or how to accomplish this task? Code: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>The Shocking Truth - Cabot Market Letter</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("#vid").show(); $("#div2").hide(); }); var test = 1; function manipulatetest() { test = 2; } window.onbeforeunload = onbeforeunload_Handler; function onbeforeunload_Handler() { if (test == 1){ $("#vid").hide(); $("#div2").show(); var confirm = confirm("Would you like to stay on this page?"); if (confirm == true) { window.location = "http://www.google.com"; } } } </script> </head> <style type="text/css"> body { background-color: #e0e6e5; } #vid { margin: 20px auto; width: 920px; } </style> <body> <div id="vid"> <video width="920" height="540" autoplay preload controls> <source src="shockingtruth.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> <source src="shockingtruth.webm" type='video/webm; codecs="vp8, vorbis"'> <source src="shockingtruth.ogv" type='video/ogg; codecs="theora, vorbis"'> <object width="920" height="540" type="application/x-shockwave-flash" data="flowplayer-3.2.1.swf"> <param name="movie" value="flowplayer-3.2.7.swf" /> <param name="allowfullscreen" value="true" /> <param name="flashvars" value='config={"clip": {"url": "http://www.cabot.net/videos/shocking-truth/shockingtruth.mp4", "autoPlay":true, "autoBuffering":true}}' /> <p>Download video as <a href="pr6.mp4">MP4</a>, <a href="pr6.webm">WebM</a>, or <a href="pr6.ogv">Ogg</a>.</p> </object> </video> </div> <div id="div2"> <video width="920" height="540" autoplay preload controls> <source src="shockingtruth.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'> <source src="shockingtruth.webm" type='video/webm; codecs="vp8, vorbis"'> <source src="shockingtruth.ogv" type='video/ogg; codecs="theora, vorbis"'> <object width="920" height="540" type="application/x-shockwave-flash" data="flowplayer-3.2.1.swf"> <param name="movie" value="flowplayer-3.2.7.swf" /> <param name="allowfullscreen" value="true" /> <param name="flashvars" value='config={"clip": {"url": "http://www.cabot.net/videos/shocking-truth/shockingtruth.mp4", "autoPlay":true, "autoBuffering":true}}' /> <p>Download video as <a href="pr6.mp4">MP4</a>, <a href="pr6.webm">WebM</a>, or <a href="pr6.ogv">Ogg</a>.</p> </object> </video> </div> <p style="text-align: center;"><a href="http://www.cabot.net/info/cml/cmlld03.aspx?source=ed01" onclick="manipulatetest();">Click Here To Order</a></p> </body> </html> Ok, im stuck. Ive tryed about 10 solutions from Google. None are working. Ok, I made a site in Flash, and a second site in HTML. I want to automatically redirect people from my flash site (indexhigh.html) to my html site (indexlow.html) if they can't see my flash movie. Here's the flash page URL: http://testnewsite.netau.net/indexhigh.html . Restrictions: This redirect MUST be done using javascript or without having me to download another swfobject file. Please paste completed code. Heres my current code: Code: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Website</title> <script language="javascript">AC_FL_RunContent = 0;</script> <script src="AC_RunActiveContent.js" language="javascript"></script> </head> <body bgcolor="#ffffff"> <!--url's used in the movie--> <!--text used in the movie--> <!-- saved from url=(0013)about:internet --> <script language="javascript"> if (AC_FL_RunContent == 0) { alert("This page requires AC_RunActiveContent.js."); } else { AC_FL_RunContent( 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0', 'width', '940', 'height', '940', 'src', 'Website', 'quality', 'high', 'pluginspage', 'http://www.macromedia.com/go/getflashplayer', 'align', 'middle', 'play', 'true', 'loop', 'true', 'scale', 'showall', 'wmode', 'window', 'devicefont', 'false', 'id', 'Website', 'bgcolor', '#ffffff', 'name', 'Website', 'menu', 'true', 'allowFullScreen', 'false', 'allowScriptAccess','sameDomain', 'movie', 'Website', 'salign', '' ); //end AC code } </script> <noscript> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="940" height="940" id="Website" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="allowFullScreen" value="false" /> <param name="movie" value="Website.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="Website.swf" quality="high" bgcolor="#ffffff" width="940" height="940" name="Website" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </noscript> <table width="889" border="2" cellspacing="0" cellpadding="0"> <tr> <td width="91" bgcolor="#FFFFFF">Site created by:</td> <td width="232"><a href="http://www.christoff.tk"><img src="my_Logo.png" width="197" height="169"></a></td> <td width="242"><a href="http://www.fcw.comoj.com"><img src="logo3.JPG" width="205" height="62"><br> Free Charity Websites </a></td> <td width="112">And by the</td> <td width="198"><p><img src="untitled.png" width="77" height="86"><br> Fort Myers High School <br> Web Design 2 Students from<br> 1st Period<br> Team leader: Chris Christoff </p></td> </tr> </table> </body> </html> Chris I need the code for if the user enters in a code into the field for example E1 and clicks submit it'll redirect them to a certain form. And if another user entered in E2 it would redirect them to a DIFFERENT form. I hope this is the correct category of the site for me to post this. Wasn't sure if it should be here or PHP.
Hi, I am facing a problem in passing replace() function as an argument in user defined java function, can any one help me how to resolve it? intention is to pass a file path to my user defined function, but before passing the path i want to replace the character '\' to '\\' I am posting my javascript function he <a href="#" onclick="OpenDocPreview('<%# Eval("PATH")%>'.replace(/\\/g,"\\\\"), '<%# Eval("Filename")%>')"><%# Eval("DocTitle") %></a> function OpenDocPreview(url, docname) { alert('message from search base : ' + url + ' ' + docname); } thank you, Hi, Please i am not getting clear understanding of a javascript code to redirect user to a different web page based on the day of the week. Please i have search for many script and not getting clear understanding from their code.I have also try several code myself but nothing good has come from it. Please can someone help me and write a descriptive code for me to understand better.I really plead you and your to help me...but i belief the Lord God will bless you for your time helping me. looking forward to here from you. Thank you. Clement Osei Here's my firstly: PHP Code: <?php echo "<script language=\"javascript\" type=\"text/javascript\"> var g_iCount = new Number(); // CHANGE THE COUNTDOWN NUMBER HERE - ADD ONE TO IT // var g_iCount = 6; function startCountdown(){ if((g_iCount - 1) >= 0){ g_iCount = g_iCount - 1; numberCountdown.innerText = 'You must wait ' + g_iCount +' seconds before your download starts'; setTimeout('startCountdown()',1000); } } function top() { setTimeout('startCountdown()',0000); setTimeout('delayer()',6000); } function delayer() { window.location = \"http://www.mediaphiles.net/uploads/".$actualname."\" } </script>"; ?> Don't worry about the $actualname variable, that is working. What I have it doing is when you click a button it starts top() which starts the countdown. Then, after 5 seconds (6 seconds) it redirects. But it doesn't seem to be working. -- I'm new to Javascript so I have no idea what the problem is. Hey there world. I'm not one for making my own scripts, so not quite sure about the best way to go about doing this. I've got a form with 2 different sets of radio buttons. Upon submitting, I'd like to redirect the user to a certain page, based on the selections they made among the radio buttons. Thanks in advance. I have a simple javascript for validating the radio buttons. But for what ever reason window.location does not redirect. this is my code: <SCRIPT LANGUAGE="JavaScript"> function checkRadio (frmName, rbGroupName) { var radios = document[frmName].elements[rbGroupName]; for (var i=0; i <radios.length; i++) { if (radios[i].checked) { return true; } } return false; } function valFrm() { if ( checkRadio("frm1","radio1")==true && checkRadio("frm1","radio2")==true) window.location="price.jsp"; else alert("You didnt select any price"); } </script> when i replace an alert with the redirect line it works fine. any help would be appreciated. I can't seem to figure out how to do this. I want the user to hit the submit button on the form and then have a few conditional statements ran to if they left any blank textfields and to see if a certain textfield contains numbers. Then I want the user to be directed to a new page if the statements are true. Here is the function code: Code: <script type="text/javascript"> function notEmpty(elem, elem1, elem2, helperMsg, helperMsg2){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); return false;} if(elem1.value.length == 0){ alert(helperMsg); elem.focus(); return false;} if(elem2.value.length == 0){ alert(helperMsg); elem.focus(); return false;} var alphaExp = /^[a-zA-Z]+$/; if(elem1.value.match(alphaExp)){ return true; }else{ alert(helperMsg2); elem.focus(); return false;} return true; } </script> And here is the form code: Code: <center> <div id="main"> <form align="center" method="post" action="/wamp/www/recipesubmit2.php"> <font color="red"><i>* = Required Field</i></font> <table border="0" bordercolor="darkblue"> <tr><td align="right"><font color="red">*</font>Recipe Name:</td><td><input type='text' id='recipeName' size=50></td></tr> <tr><td></br></td></tr> <tr><td align="right"><font color="red">*</font>Ingredients:</td><td><input type='text' id='ingredients' size=50></td></tr> <tr><td></td><td><font font size="2" color="red">Reminder: </font><font font size="2">Make sure you put a space between each ingredient.</br>Example: <b>chicken cream of mushroom soup</b>. DO NOT PUT</br>MEASUREMENTS! It is also important to correctly spell the</br>ingredients otherwise your recipe may not be found when searched.</td></tr> <tr><td></br></td></tr> <tr><td align="right"><font color="red">*</font>Directions:</td><td><textarea id='description' cols=50 rows=10></textarea></td></tr> <tr><td></br></td></tr> <tr><td align="right"><font color="red">*</font>Cook/Prep Time:</td> <td><select name="cooktimedrop"> <option value="zerofive">0-5</option> <option value="sixten">6-10</option> <option value="elevenfifteen">11-15</option> <option value="sixteentwenty">16-20</option> <option value="twentyonetwentyfive">21-25</option> <option value="twentysixthirty">26-30</option> <option value="thirtyonethirtyfive">31-35</option> <option value="thirtysixforty">36-40</option> <option value="fortyonefortyfive">41-45</option> <option value="fortysixfifty">46-50</option> <option value="fiftyonefiftyfive">51-55</option> <option value="fiftysixsixty">56-60</option> <option value="sixtyoneplus">61+</option> </select> minutes</td> <tr><td></br></td></tr> <tr><td align="right"><font color="red">*</font>Gen </td> <td><select name="genredrop"> <option value="alcoholic">Alcoholic</option> <option value="appetizers">Appetizers</option> <option value="beverages">Beverages</option> <option value="breads">Breads</option> <option value="breakfast">Breakfast</option> <option value="cakes">Cakes</option> <option value="candies">Candies</option> <option value="casseroles">Casseroles</option> <option value="cookies">Cookies</option> <option value="crockpot">Crockpot</option> <option value="desserts">Desserts</option> <option value="dipsdressings">Dips/Dressings</option> <option value="entrees">Entrees</option> <option value="fatfree">Fat Free</option> <option value="georgeforeman">George Foreman</option> <option value="halal">Halal</option> <option value="herbal">Herbal</option> <option value="italian">Italian</option> <option value="jams">Jams</option> <option value="jello">Jell-O</option> <option value="lowfat">Low Fat</option> <option value="mexican">Mexican</option> <option value="puddings">Puddings</option> <option value="rice">Rice</option> <option value="salads">Salads</option> <option value="sauces">Sauces</option> <option value="seafood">Seafood</option> <option value="snacks">Snacks</option> <option value="soups">Soups</option> <option value="vegan">Vegan</option> <option value="vegetarian">Vegetarian</option> <tr><td></br></td></tr> <tr><td align="right">Submitted By:</td><td><input type='text' id='submittedBy' size=40></br></td></tr> <tr><td></br></td></tr> <tr><td></td><td align="right"><input type='submit' onsubmit="notEmpty(document.getElementById('recipeName'), document.getElementById('ingredients'), document.getElementById('description'),'You have not filled in all required fields.', 'I thought I said no measurements! (No Numbers)')" value='Submit Recipe'></td></tr> </form> </div> </center> This is what I tried but alas, it does not work por que no? This is located on my main index file which if the result of z is greater than 1, I would have the user stay at this page as opposed to redirecting to the portrait design. I have optimized the website for mobile use so there is a reason of having two different pages, the wide screen has extra tools / other stuff that isn't shown on the portrait not because of size/responsive design but becasue I want it to be this way. Anyway... "What's the situation captain?" This is located above my <style> tag Code: <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> <script language="JavaScript" type="text/javascript"> <script> function redirect() { var x = screen.width; var y = screen.height; var z = x/y; if (z<1) { window.location.replace("alternate destination"); }; else ( ){ // stay here }; }; </script> Reply With Quote 12-21-2014, 01:58 AM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts You have extra semicolons in there. In general, don't put a semicolon directly after a right brace }; There are a couple of exceptions, but they don't apply here. What's the point in having the else?? I have a bunch of questions and know very little javascript. (I come from a world of Visual basic) I would spend the time to learn a lot more about it, but i dont have that time since this program needs to be done by tuesday. Question 1: Do i save the text from textbox a user inputs to a variable like this when a submit button is clicked?: var tb1=textbox1.text Question 2: To activate or call that variable on the click of a button do i do this?: <form> <input type="button" value="text" onlick="tb1"/> </form> I have a bunch of questions, but i will ask them later when i know how to state them better. I have the two functions below, I want to write a function that puts them into a chart, I have the chart sorted etc but just struggling with how to get the actual validated users inputs from these two functions into the chart, I've tried document.write('<td> $' + productIndex + '</td>'); into the chart but that wouldn't work anyway as there could be multiple inputs? Just need a way to get the output really. function getProductChoice(min, max) { var getProductChoice = function(min, max){ do{ var productIndex = parseInt(prompt('Enter your product choice; 0-5', '0')); } while( isNaN(productIndex) || productIndex < min || productIndex > max); }; getProductChoice(0,5); } function getProductQuantity(max) { do{ var productIndexQuantity = parseInt(prompt('How many would you like?', '0')); } while( isNaN(productIndexQuantity) || productIndexQuantity < 0 || productIndexQuantity > max); }; getProductQuantity(MAX_QUANTITY); How would I add up a array of numbers in a function? My numbers keep getting written as strings, instead of adding onto each other. I am a beginner. function (myNumbers) { var number = [6,9,10,13,14]; var total = 0; for(var total=0; total < number.length; total = total + 1) { total = total + number; document.write(total); } } myNumbers(); This is just an excercise. Hi there, I've been scouring the web and my mind for the last 24 hours trying to find a script that will work for what I need. It seems like it would be something super simple. I need visitors to my site to be able to search if we offer service in their area. i.e. Enter Zip Code: [Search Field] (Submit Button) Pop-up results or a results page with one of two responses. Yes, we offer service. No, we do not cover your area. Something similar to what this company has on their site, http://www.oilpatchfuel.com/Pages/Welcome.aspx Any help is a greatly GREATLY appreciated!! Goodafternoon! What im trying to do is get the users location (from the iPhone) which I have working and store it in a MySQL database (semi works). My problem is that to get the location, you need to use javascript. So I thought of using Ajax to post that back to the server. I have very little knowledge in Javascript, and Ajax, so this has been a bit of a struggle. Iv tried to learn how to do it with a tutorial: http://www.tizag.com/ajaxTutorial/ajax-javascript.php And this is what I got: PHP Code: <?php function is_iPhone($agent='') { if(empty($agent)) $agent = $_SERVER['HTTP_USER_AGENT']; if(!empty($agent) and preg_match("~Mozilla/[^ ]+ \((iPhone|iPod); U; CPU [^;]+ Mac OS X; [^)]+\) AppleWebKit/[^ ]+ \(KHTML, like Gecko\) Version/[^ ]+ Mobile/[^ ]+ Safari/[^ ]+~",$agent,$match)) { return "YES"; } elseif(stristr($agent,'iphone') or stristr($agent,'ipod')){ return "MAYBE"; } else { return "NO"; } } echo is_iPhone(); ?> <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>iPhone 3.0 geolocation demo</title> <meta content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" name="viewport"/> </head> <body> <script language="javascript" type="text/javascript"> <!-- //Browser Support Code function ajaxFunction(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ document.myForm.time.value = ajaxRequest.responseText; } } ajaxRequest.open("GET", "UpdateLog.php?lat=" + Lat + "&long=" + Long + "&acc=" + Acc, true); ajaxRequest.send(null); } //--> var Lat = "" var Long = "" var Acc = "" function handler(location) { var message = document.getElementById("message"); message.innerHTML ='<img src="http://maps.google.com/maps/api/staticmap?center=' + location.coords.latitude + ',' + location.coords.longitude + '&zoom=12&size=400x400&markers=color:blue|label:S|'+ location.coords.latitude +','+ location.coords.longitude +'&sensor=true" alt="some_text"/>'; message.innerHTML+="<p>Longitude: " + location.coords.longitude + "</p>"; message.innerHTML+="<p>Latitude: " + location.coords.latitude + "</p>"; message.innerHTML+="<p>Accuracy: " + location.coords.accuracy + "</p>"; Lat = location.coords.latitude Long = location.coords.longitude Acc = location.coords.accuracy } navigator.geolocation.getCurrentPosition(handler); ajaxFunction(); </script> <div id="message">Location unknown</div> <a href="#" onclick="ajaxFunction();" >Send</a> </body> </html> Now this works if the user clicks on "Send" that I made, but I want it to do it without the user having to click send. If anyone could help me with this, or point me in a different direction that would be better then your help would be greatly appreciated. Thanks in advance for your help. EDIT: The PHP side of this works, that is something I know about lol. Code: function splook(val){ return speciesDB.queryBy(function(row){ return row.data.species_id == val; }).itemAt(0).data.speciesDB; } and the speciesDB Code: {success:true,rows:[{"species_id":"1","species_idx":"1","species":"Boa Constrictor"},{"species_id":"2","species_idx":"2","species":"Ball Python"},{"species_id":"3","species_idx":"3","species":"Reticulated Python"},{"species_id":"4","species_idx":"4","species":"SriLanka Python"},{"species_id":"5","species_idx":"5","species":"Blood Python"},{"species_id":"6","species_idx":"6","species":"Burmese Python"}]} I need to take val and match it with the data and return species. I just can't figure it out though! Thanks! Hello I would like to know how this is not functional. surely passing the function to another function would work so I can use the same variables without having to write it out again. [ICODE] <html> <head> <title>Number Conversions</title> <script> function addNumbers () { var firstnumber = document.calculator.myFirstNumber.value; var secondnumber = document.calculator.mySecondNumber.value; var total = parseInt(firstnumber) + parseInt(secondnumber); document.calculator.myTotal.value = total; document.calculator.myHex.value = total.toString(16); document.calculator.myOct.value = total.toString(8); document.calculator.myBinary.value = total.toString(2); document.write("End of Calculation."); } function subtractNumbers (addNumbers) { var total = parseInt(firstnumber) - parseInt(secondnumber); } </script> </head> <body> <form name="calculator"> First Number <input type=text name="myFirstNumber" value=0 size=3> <br> Second Number <input type=text name="mySecondNumber" value=0 size=3><br><br> <input type="button" value="ADD" onclick="addNumbers();"> <input type="button" value="SUBTRACT" onclick="subtractNumbers();"><br> Total <input type=text name="myTotal" value=0 size=3><br> Binary <input type=text name="myBinary" value=0 size=8><br> Octal <input type=text name="myOct" value=0 size=3><br> Hexidecimal <input type=text name="myHex" value=0 size=3><br> </form> </body> </html> [ICODE] I made a 50th anniversary guestbook to add memories/etc about our organization. The people can look at the entries and then if they want to add one of there own, there's a link that should pop up a form in a new for them to add it. I have no idea why this pop is not working in Internet Explorer (both IE6 and 7). It works beautifully in Firefox. I have no idea how you can go wrong with window.open. I'm stuck. Again, only the actual pop up function doesn't work. Everything else seems to be working fine. I included all of my code though even for the tab navigation because the link to the pop up form changes based on what tab they are in (i.e. if they're looking at the past memories tab and click on the link, it takes them to the past memories form). I know it's probably TMI on the code, but I thought it might be somehow related and better safe than sorry, right? HTML Page Code: <html> <head> <title>50th Anniversary Reflections</title> <script type="text/javascript" src="js/guestbook.js"></script> <link href="css/guestbook.css" media="all" type="text/css" rel="stylesheet"> </head> <body> <div id="guestbook_container"> <div id="tab_nav_container"> <ul> <li><div id="tab_1" class="tabs_on" onclick="tabsClass.switchTab(this);"><a target="gstbk_frame" href="guestbook_query.asp?cat=1" onclick="change_value(1);">Past Memories</a></div></li> <li><div id="tab_2" class="tabs_off" onclick="tabsClass.switchTab(this);"><a target="gstbk_frame" href="guestbook_query.asp?cat=2" onclick="change_value(2);">Career Impact</a></div></li> <li><div id="tab_3" class="tabs_off" onclick="tabsClass.switchTab(this);"><a target="gstbk_frame" href="guestbook_query.asp?cat=3" onclick="change_value(3);">Future Wishes</a></div></li> <li><div id="new" class="tabs_off" onclick="popupform();">Share Your Memories</div></li> </ul> </div><!-- end tab_nav_container --> <div id="tab_content_container"> <div id="tab_1_data" class="tab_content"><p class="tab_category">What is your most important memory of NACUA?</p></div> <div id="tab_2_data" class="tab_content" style="display: none;"><p class="tab_category">How has NACUA benefitted you and your career?</p></div> <div id="tab_3_data" class="tab_content" style="display: none;"><p class="tab_category">What is your most important wish or hope for NACUA's future?</p></div> </div><!-- end tab_content_container --> <script type="text/javascript"> tabsClass.addTabs("tab_nav_container"); </script> <br class="clear" /> <div id="iframe_container"> <iframe name="gstbk_frame" id="gstbk_frame" src="guestbook_query.asp?cat=1" width="730px" height="550px" scrolling="auto" frameborder="none"></iframe> </div><!-- end iframe_container --> <br class="clear" /> </div><!-- end guestbook_container --> </body> </html> Here's the guestbook.js file: Code: //***** ASSIGN/CHANGE CATEGORY VALUES ***** function popupform(){ var href; href="guestbook_submission_form.asp?cat="+catValue; window.open(href, "Submission Form", 'width=600, height=400, scrollbars=no'); } var catValue = "1" function change_value(catChange){ catValue=catChange; change_text(); } function change_text(){ if(catValue=="1"){ document.getElementById("new").innerHTML = "<a href='#' style='color:#ffffff;'>Share Your Memories!</a>"; } if(catValue=="2"){ document.getElementById("new").innerHTML = "<a href='#' style='color:#ffffff;'>Share Your Career Experiences!</a>"; } if(catValue=="3"){ document.getElementById("new").innerHTML = "<a href='#' style='color:#ffffff;'>Add Your Own Wish!</a>"; } } //***** ASSIGN/CHANGE VALUES AND TABS ***** function assignCategory(cat){ document.form.category.value=cat; } function onLoadAssignAndSwitch(cat){ assignCategory(cat); tabsClass.addTabs("tab_nav_container"); var initialTab = "tab_" + cat + "_data" if (initialTab != "tab_1_data"){ document.getElementById(initialTab).style.display = ""; document.getElementById("tab_1_data").style.display = "none"; } document.getElementById("tab_" + cat).className = "tabs_on"; } function assignAndSwitch(element, cat){ tabsClass.switchTab(element); assignCategory(cat); } //***** TABBED MENU ***** var tabsClass = { tabSetArray: new Array(), classOn: "tabs_on", classOff: "tabs_off", addTabs: function (tabsContainer) { tabs = document.getElementById(tabsContainer).getElementsByTagName("div"); for (x in tabs) { if (typeof(tabs[x].id) != "undefined") { this.tabSetArray.push(tabs[x].id); } else {} } }, switchTab: function (element) { for (x in this.tabSetArray) { tabItem = this.tabSetArray[x]; dataElement = document.getElementById(tabItem + "_data"); if (dataElement) { if (dataElement.style.display != "none") { dataElement.style.display = "none"; } else {} } else {} tabElement = document.getElementById(tabItem); if (tabElement) { if (tabElement.className != this.classOff) { tabElement.className = this.classOff; } else {} } else {} } document.getElementById(element.id + "_data").style.display = ""; element.className = this.classOn; } }; I'm not that advanced in javascript (although not a total idiot) Any help and/or suggestions would be greatly appreciated! Thank you! |