JavaScript - Sessionsel.selectedindex Is Undefined
Please help, My session_type_id is not being passed through?!
I get the following error: SessionSel.selectedIndex is undefined JavaScript Code: function confirmsession() { var SessionID = document.getElementById('session_type_id').value; var SessionSel = document.getElementById('session_type_id');// that is all: no value var SettingSession = SessionSel.options[SessionSel.selectedIndex].text; var answer = confirm("Delete entry "+SettingSession+" ?") if (answer){ alert("System Deleted") window.location = "delete_session_type.php?session_type_id="+SessionID; } else{ alert("No action taken") } } HTML Code: <input type="hidden" id="session_type_id" value="'.$row1['session_type_id'].'" /> echo '<td><input type="image" src="images/close.gif" height="16" width="16" name="remove" value="remove" onClick="javascript:confirmsession()" /></td>'; Similar TutorialsI am getting an error: "document.getElementById("gender") is null" Any ideas how I can get this to work? Code: <head> <script type="text/javascript"> var selected = document.getElementById("gender").selectedIndex; var lname = document.getElementById("lastname"); var boyarray=new Array(); boyarray[0]="Joseph James"; boyarray[1]="Robert Michael"; boyarray[2]="Brian Shawn"; boyarray[3]="Joseph Duke"; var boymax=(boyarray.length - 1); var boychoose = Math.round(Math.random() * boymax); var girlarray=new Array(); girlarray[0]="Christine Louise"; girlarray[1]="Cheyenne Lynn"; girlarray[2]="Kelly Anne"; girlarray[3]="Julia Marie"; var girlmax=(girlarray.length - 1); var girlchoose = Math.round(Math.random() * girlmax); function randomname() { if (selected = "2") { alert((girlarray[girlchoose]) + lname); } else if (selected="1") { alert((boyarray[boychoose]) + lname); } else { alert("Please select a gender."); } } </script> </head> <body> <form onsubmit="randomname(this);"> Last Name:<input type="text" name="lastname" id="lastname"/> <br/> Gender: <select id="gender"> <option value="0">Please select a gender</option> <option value="1">Boy</option> <option value="2">Girl</option> </select> <br/> <input type="submit" id="submit" name="submit" value="Submit"/> </form> </body> I knocked up the following code in response to a recent question in this forum, but it has a defect which I can't overcome. If the user types "a" then the select box is populated with "Choose An Animal...", then the three three animals beginning with A. So far so good. But if the user selects say Albatross and then types the letter b then the option "Bear" is selected rather than "Choose An Animal". Although the code is sel.selectedIndex = 0; (not 1). Question - How can I force the selected index to 0 when a choice has been made previously? Is this a bug - if so it is the same in IE and FF. Code: <html> <head> </head> <body> <form name = "myform"> <select id = "mysel" onchange = "alertValue()"> </select> </form> <script type = "text/javascript"> function alertValue() { var x = document.getElementById("mysel").value; alert ("You selected " + x); } var words65 = ["Albatross","Anteater", "Aardvark"]; var words66 = ["Bear", "Bat","Bison", "Bobcat"]; var words67 = ["Cat", "Cougar","Canada Goose", "Caribou"]; var key; document.onkeydown = function(ev) { ev = ev || event; key = ev.keyCode; if ((key >= 65) && (key <= 90)) { // a-z tmp = eval("words" + key); var sel = document.getElementById("mysel"); sel.options.length = 0; sel.options[0] = new Option('Choose An Animal...','',true,true); // text value defaultSelected selected for (var i=0; i<tmp.length; i++){ if (tmp[i]) { sel.options[sel.options.length]=new Option(tmp[i],tmp[i],false,false); // text value defaultSelected selected } } sel.selectedIndex = 0; // WHY DOES THIS NOT WORK? } } </script> </body> </html> I was playing around with JavaScript today, just seeing if I could make image rollovers. I successfully switched out the first image, but I couldn't get it switched out with the original. My code: Code: window.onload = initAll; function initAll() { // var nav = document.getElementById("navigation"); var patt = /^http:\/\/www\.[a-z\/\.-]+\.jpe?g$/i; for (var i = 0; i < document.images.length; i++) { if (patt.test(document.images[i].src)) { document.images[i].onmouseover = switchy; var newbySrc = document.images[i].src; document.images[i].onmouseout = function() { UNswitchy(newbySrc); } } } } function switchy() { var newbert = new Image(); // the image below is the same one for every image, as I'm just testing newbert.src = "http://www.hogwarts-rpg.net/images/buttons/home.jpg"; this.src = newbert.src; } function UNswitchy(myImgSrc) { var newBern = new Image(); newBern.src = myImgSrc; this.src = newBern.src; } Since taking the mouse off the image wouldn't switch it back, I guessed that the UNswitchy() function was messing up. So, I commented out the code in there and added alert(), and alert() told me that this.src (in UNswitchy()) was undefined. Why would it be, since it worked fine in switchy()? I have two google maps loading on my page. The first loads with a body onload call the second when a button is clicked. After the button is clicked I get the error message "map is not defined". I have reviewed my code and I can not see where I have forgotten to define a var (if I am understanding the error messaage correctly - I assume that is the problem)". My code is: Code: <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html {height:250px} body {height:250px} #map_canvas {width:30%; height:250px;} #placemap_canvas {width:100%; height:250px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" /> </script> <script type="text/javascript"> function initialize() { var latlng = new google.maps.LatLng ( <?php include("dbconnect.php"); $result = mysql_query("SELECT * FROM countries WHERE Country='{$_SESSION['Country']}'"); while($row = mysql_fetch_array($result)){ echo $row['Map']; } mysql_close($con); ?>); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } </script> //Here starts the code for the second map called by a button click <script type="text/javascript"> var geocoder; var submap; function createGMapFromAddress(){ geocoder = new google.maps.Geocoder(); var sublatlng = new google.maps.LatLng(0,0); var map_options = { zoom: 4, center: sublatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var submap = new google.maps.Map(document.getElementById("placemap_canvas"), map_options); } function codeAddress(location){ alert(location); var address = location; alert(address); geocoder.geocode({address: address}, function(results, status){ if (status == google.maps.GeocoderStatus.OK && results.length){ if (status != google.maps.GeocoderStatus.ZERO_RESULTS){ map.set_center(results[0].geometry.location); } } else { alert("Geocode was unsuccessful due to: " + status); } }); } </script> I am trying to read data from excel file and use the same to populate a select menu. If any cells are blank, I want to ignore. But I am unable to do this. The dropdown gets populated with blanks. Following is the peice of code: var excel_cell = excel_file.ActiveSheet.Cells(i,1); alert(excel_cell); if(excel_cell=='undefined') ; else document.forms.form1.Products.add(new Option(excel_cell,excel_cell)); I am unable to check for undefined. How do I handle this ?? Hi, Ihave this html/jscript hybrid and when i run it in firefox the error console says a value is undefined when i click it the very first <html> is highlighted???? any one no why? New to javascript, so I'm trying to work through a rather older, but helpful nonetheless book entitled "Head Rush Ajax". I'm only finishing up the first chapter...lol and my code is not doing what its supposed to be doing. I'm sure its something simple like a typo, but I have been over it several times and cant spot the problem. When I try to run the script in IE8, it throws an error saying object expected. line 43 code 0 Here is my complete script. According to the book I should be able to click the button and the values will update only once. PHP Code: var request = null; function createRequest() { try { request = new XMLHttpRequest(); } catch (trymicrosoft) { try { request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { request = null; } } } if (request == null) alert("Error creating request object!"); } function getBoardsSold() { createRequest(); var url="getUpdatedBoardSales-ajax.php"; request.open("GET", url, true); request.onreadystatechange = updatePage; request.send(null); } function updatePage() { if (request.readyState == 4) { var newTotal = request.responseText; var boardsSoldEl = document.getElementById("boards-sold"); var cashEl = document.getElementById("cash"); replaceText(boardsSoldEl, newTotal); // Figure out how much cash katie has made var priceEl = document.getElementById("price"); var price = getText(priceEl); var costEl = document.getElementById("cost"); var cost = getText(costEl); var cashPerBoard = price - cost; var cash = cashPerBoard * newTotal; //update the cash for the slopes on the form cash = Math.round(cash * 100) / 100; replaceText(cashEl, cash); } } Thanks for any help in advance! When I try to assign an object to an array I get the error: Uncaught TypeError: Cannot set property '0' of undefined The array is defined as: Code: var animation_JD = [[]]; Here i try to assign an object (was working fine with single dimension array) Code: animation_JD[group][animationID] = (animation); More code if people would like it: Code: var group = params.group || "default"; var animationID = getNextID_animator_JD(group); animation = new Object(); animation.repeat = params.repeat || "1"; animation.wait = params.wait || "never"; animation.currentStage = 0; animation.currentFrame = 0; animation.active = false; animation.running = false; animation_JD[group][animationID] = (animation); return animationID; i am getting an error according to firebug of 'id_con is undefined'.i have made sure all entries are correct and i cannot see how to fix this error. i would be grateful if someone could show me how to correct this error. the error is occuring on this line: Code: itemlist+= items[i].id_con.substr(3)+","; Code: <script src="js/jquery.js"></script> <script src="js/flexigrid.js"></script> <link rel="stylesheet" href="css/flexigrid/flexigrid.css" type="text/css" /> <script type="text/javascript"> $(function() { $("#flex1").flexigrid( { url: 'staff.php', dataType: 'json', colModel : [ {display: 'ID', name : 'id_con', width : 40, sortable : true, align: 'left'}, {display: 'Name', name : 'name_con', width : 150, edit: true, sortable : true, align: 'left'}, {display: 'Email', name : 'email_con', width : 150, sortable : true, align: 'left'}, {display: 'Phone', name : 'phone_con', width : 250, sortable : true, align: 'left'}, {display: 'Mobile', name : 'mobile_con', width : 150, sortable : true, align: 'left'}, {display: 'Fax', name : 'fax_con', width : 150, sortable : true, align: 'left'}, {display: 'Notes', name : 'notes_con', width : 250, sortable : true, align: 'left'} ], buttons : [ {name: 'Add', bclass: 'edit', onpress : test}, {separator: true}, {name: 'Edit', bclass: 'edit', onpress : test}, {separator: true}, {name: 'Delete', bclass: 'delete', onpress : test}, {separator: true} ], searchitems : [ {display: 'Name', name : 'name_con', isdefault: true}, {display: 'Email', name : 'email_con'} ], sortname: "id_con", sortorder: "asc", usepager: true, title: "Staff", useRp: true, rp: 10, showTableToggleBtn: false, resizable: false, autowidth: true, autoheight: true, singleSelect: true } ); }); function test(com,grid) { if($('.trSelected',grid).length>0){ if(confirm('Delete ' + $('.trSelected',grid).length + ' items?')){ var items = $('.trSelected',grid); var itemlist =''; for(i=0;i<items.length;i++){ itemlist+= items[i].id_con.substr(3)+","; } $.ajax({ type: "POST", dataType: "json", url: "delete1.php", data: "items="+itemlist, success: function(data){ alert("Query: "+data.query+" - Total affected rows: "+data.total); $("#flex1").flexReload(); } }); } else if (com=='Add') { alert('Add New Item'); } else if (com=='Edit') { alert('Edit Item'); } } $('b.top').click ( function () { $(this).parent().toggleClass('fh'); } ); } </script> getting undefined alert. Why? Code: <script> function openFile(f){ alert(f); } </script> File Location: <a onclick="openFile(this.value)"; > Click to view File</a> <BR> <textarea name = "fileLoc">TEST VALUE</textarea> I am transferring my pages to using templates and it works well. I now came to a page where I play a sound when the mouse is over the picture and stops when it leaves. I added two items to the 'pix' array to include this and did the same way as I've done before but now when the mouse enters a picture I get errors "'mouseOver' is undefined" and "'mouseOut' is undefined". Can anyone spot the error? test.php Code: <h1>PICTURE TEST</h1> <div id="contents"></div> <script> var pix = [ {figu "figure", picfile:"bp/p01.jpg", alternative: "pic1", caption: "Picture 1", mouseOver: "sJoid.play();", mouseOut: "sJoid.stop();"} ]; $.get("/tmpl/_test.tmpl.htm", function(templates) { $("#contents").empty(); $("#contents").append(templates); $("#testTemplate").tmpl(pix).appendTo("#contents"); }); </script> _test.tmpl.htm Code: <script id="testTemplate" type="x-jquery-tmpl"> <img src="/pics/${picfile}" alt="${alternative}" onmouseover="$(mouseOver)" onmouseout="$(mouseOut)" /> </script> I've been working through a tutorial on OOP in javascript. Upon keyup, the code below gives this error: Quote: charCounterObj[x] is undefined This is my first attempt at anything like this, so apologies for what are no doubt egregious and fundamental misunderstnadings about how to implement something like this. I've stripped away everything that's irrelevant, but there's still quite a bit of code here. I'm hoping this isn't too much wade through, but perhaps someone would be kind enough to give it the once-over. There may be something obvious that jumps out to the seasoned eye... Code: //CharCounter Class function charCounterClass(formType) { //Properties this.counter = $('#'+formType+'_commentsCounter'); this.textarea = $('#'+formType+'_comment'); this.maxlength = $('#'+formType+'_commentMaxlength').text(); this.textLen = this.textarea.val().length; //Methods this.cch = function() { $(this.counter).val(this.textLen); //... } } var charCounterObj = []; var charCounter = []; var x = 0; $("input.charCounter").each(function() { charCounter[x] = $(this).val(); if (charCounter[x] == true) { charCounterObj[x] = new charCounterClass(formType[x]); $('#'+formType[x]+'_comment').keyup(function() { charCounterObj[x].cch(); }); } x++; }); Thanks for any input. Hi, I'm not sure did I post this to the right area, but here's my problem... Let's make this simple, I am totally newbie in coding. I installed a lightbox patch to FCKeditor, and I tried to modify it a bit so I could add a title into it. I kind of managed but... Here's the html code which I added to the html file: Code: <div> <br /> <input id="txtTitleLightBox" style="width: 100%" type="text" /> </div> And these are the modified codes which I added to the js file: Code: var rel = oLink.rel; if (rel) { var type; if (rel.indexOf("[") > 0) type = rel.substring(0,rel.indexOf("[")); else type = rel; var oE = GetE('rad'+type); if (oE) { GetE('txtTitleLightBox').value= title; GetE('txtGroupLightBox').value= rel.substring(rel.indexOf("[")+1, rel.indexOf("]")); GetE('chkLightBox').checked = true; GetE('rad'+type).checked = true; } } Code: if (GetE('chkLightBox').checked && oLink) { var rel = "lightbox" var rad = document.getElementsByName('radLightBoxType') for (var i=0; i < rad.length; i++) { if (rad[i].checked) { rel = rad[i].value; break; } } oLink.title = title var title = GetE('txtTitleLightBox').value = title; oLink.rel = rel var group = GetE('txtGroupLightBox').value if (group) { oLink.rel += "[" + group + "]" } } And what I added as new code were Code: oLink.title = title var title = GetE('txtTitleLightBox').value = title; and Code: GetE('txtTitleLightBox').value= title; The result is (eg) this kind of html text: Code: <a title="undefined" rel="lightbox" href="image/path"><img width="200" height="113" alt="" src="image/path" /></a> So the title is undefined even if I fill something to the txtTitleJavaScript box... If you want to investigate the full files, they are he http://jump.fm/IYOXH .. thanks :s I am trying to build a status string for all the checkboxes on a form. If the checkbox is checked add 127 to the string else add 0 to the string. All works fine until i have just 1 checkbox on the form. I then get an undefined error from alert(checkBoxes.length); Any ideas ? Code: HTML <form name="myform" method="POST" action="" onsubmit="return checkTheBox();"> <ul> <li> <input type="checkbox" name="col_box[]" /> </li> <li> <input type="checkbox" name="col_box[]" /> </li> </ul> <input type="submit" value="Submit Form" /> </form> JAVASCRIPT <script type = "text/javascript"> function checkTheBox() { var checkbox_status =""; var checkBoxes = document.myform.elements['col_box[]']; alert(checkBoxes.length); for (i = 0; i < checkBoxes.length; i++){ if(document.myform["col_box[]"][i].checked){ checkbox_status = checkbox_status + "127,"; } else { checkbox_status = checkbox_status + "0,"; } } alert (checkbox_status); } </script> Hello, I'm a JavaScript newbie and would welcome any assistance. I am getting the following error: inputField is undefined on line 19 of my js file. I have spent hours trying to figure out the problem and I am stuck. Thank you for your help!!! Here is my JavaScript code (followed by my HTML code): function validateRegEx(regex, input, helpText, helpMessage) { // See if the input data validates OK if (!regex.test(input)) { // The data is invalid, so set the help message and return false if (helpText != null) helpText.innerHTML = helpMessage; return false; } else { // The data is OK, so clear the help message and return true if (helpText != null) helpText.innerHTML = ""; return true; } } function validateNonEmpty(inputField, helpText) { // See if the input value contains any text if (inputField.name.length == 0) { /*The data is invalid, so set the help message*/ if (helpText != null) helpText.innerHTML = "Please enter the missing information."; return false; } else { //The data is OK, so clear the help message if (helpText != null) helpText.innerHTML = ""; return true; } } function validateLength(minLength, maxLength, inputField, helpText) { // See if the input value contains at least minLength but no more than maxLength characters return validateRegEx(new RegExp("^.{" + minLength + "," + maxLength + "}$"), inputField.value, helpText, "Please enter a value " + minLength + " to " + maxLength + " characters in length."); } function validateZipCode(inputField, helpText) { // First see if the input value contains data if (!validateNonEmpty(inputField, helpText)) return false; // Then see if the input value is a ZIP code return validateRegEx(/^\d{5}$/, inputField.value, helpText, "Please enter a 5-digit ZIP code."); } function validateDate(inputField, helpText) { // First see if the input value contains data if (!validateNonEmpty(inputField, helpText)) return false; // Then see if the input value is a date return validateRegEx(/^\d{2}\/\d{2}\/(\d{2}|\d{4})$/, inputField.value, helpText, "Please enter your date of birth (for example, 05/13/1959)."); } function validatePhone(inputField, helpText) { // First see if the input value contains data if (!validateNonEmpty(inputField, helpText)) return false; // Then see if the input value is a phone number return validateRegEx(/^\d{3}-\d{3}-\d{4}$/, inputField.value, helpText, "Please enter a phone number (for example, 123-456-7890)."); } function validateEmail(inputField, helpText) { // First see if the input value contains data if (!validateNonEmpty(inputField, helpText)) return false; // Then see if the input value is an email address return validateRegEx(/^[\w\.-_\+]+@[\w-]+(\.\w{2,3})+$/, inputField.value, helpText, "Please enter an email address (for example, johndoe@acme.com)."); } function placeOrder(form) { if (validateLength(1, 20, form["instrument"], form["instrument_help"]) && validateNonEmpty(form["name"], form["name_help"]) && validateNonEmpty(form["address"], form["address_help"]) && validateNonEmpty(form["city"], form["city_help"]) && validateNonEmpty(form["state"], form["state_help"]) && validateZipCode(form["zipcode"], form["zipcode_help"]) && validatePhone(form["phone"], form["phone_help"]) && validateEmail(form["email"], form["email_help"]) && validateDate(form["date"], form["date_help"]) && validateNonEmpty(form["user"], form["user_help"]) && validateNonEmpty(form["pass"], form["pass_help"])) { // Submit the information to the server form.submit(); } else { alert("I'm sorry but it appears you skipped something."); } } Here is my html: <!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> <title>Offbeat Customer Information</title> <meta name="description" content="Offbeat Music Store selling all things musical" /> <meta name="keywords" content="music, musician, instruments, musician's accessories, music, customer information, subscriptions, sales" /> <link rel="stylesheet" href="labs.css" type="text/css"/> <script type="text/javascript" src="mod7.js"></script> </head> <body onload="document.getElementById('instrument').focus()"> <div class="topbanner" align="center"> <img id="logo" src="images/offbeatlogo.png" alt="OffBeat Music Store" width="50%" height="50%" /> </div> <div id="leftcolumn"> <div class="nav"> <ul> <li><a href="mod1.html">iRock</a></li> <li><a href="mod2dq.html">Mod 2 DQ</a></li> <li><a href="mod2.html">Order Form</a></li> <li><a href="index.html">Home</a></li> <li><a href="mod4.html">SFA</a></li> <li><a href="mod5.html">Vendor Showcase!</a></li> <li><a href="mod6.html">Vendor Showcase Redux</a></li> <li><a href="mod7.html">New Customer Account Form</a></li> <li><a href="mod8.html">Mod 8</a></li> <li><a href="mod9.html">Mod 9</a></li> <li><a href="mod10.html">Mod 10</a></li> <li><a href="mod11.html">Mod 11</a></li> <li><a href="mod12.html">Mod 12</a></li> <li><a href="mod13.html">Mod 13</a></li> <li><a href="mod14.html">Mod 14</a></li> </ul><br /></div></div> <div id="rightcolumn"> <br /> <p>Join the OffBeat family and keep up to date on all of our product offerings and sales by completing this form. You'll also receive a special coupon for your birthday!</p><br /> <form name="form" action="offbeatinfo.htm" method="POST" id="form"> <div class="formfield"> What instrument do you play/are you interested in?: <input id="instrument" name="instrument" type="text" size="20" onblur="validateLength(1, 20, this, document.getElementById('instrument_help'))" /> <span id="instrument_help" class="help"></span> </div><br /><br /> <div class="formfield"> Name: <input id="name" name="name" type="text" size="32" onblur="validateNonEmpty(this, document.getElementById('name_help'))" /> <span id="name_help" class="help"></span> </div><br /><br /> <div class="formfield"> Street address: <input id="address" name="address" type="text" size="36" onblur="validateNonEmpty(this, document.getElementById('address_help'))" /> <span id="address_help" class="help"></span> </div><br /><br /> <div class="formfield"> City: <input id="city" name="city" type="text" size="36" onblur="validateNonEmpty(this, document.getElementById('city_help'))" /> <span id="city_help" class="help"></span> </div><br /><br /> <div class="formfield"> State: <input id="state" name="state" type="text" size="2" onblur="validateNonEmpty(this, document.getElementById('state_help'))" /> <span id="state_help" class="help"></span> </div><br /><br /> <div class="formfield"> ZIP Code: <input id="zipcode" name="zipcode" type="text" size="5" onblur="validateZipCode(this, document.getElementById('zipcode_help'))" /> <span id="zipcode_help" class="help"></span> </div><br /><br /> <div class="formfield"> Phone number: <input id="phone" name="phone" type="text" size="12" onblur="validatePhone(this, document.getElementById('phone_help'))" /> <span id="phone_help" class="help"></span> </div><br /><br /> <div class="formfield"> Email address: <input id="email" name="email" type="text" size="32" onblur="validateEmail(this, document.getElementById('email_help'))" /> <span id="email_help" class="help"></span> </div><br /><br /> <div class="formfield"> Your month and date of birth (MM/DD/YYYY): <input id="date" name="date" type="text" size="10" onblur="validateDate(this, document.getElementById('date_help'))" /> <span id="date_help" class="help"></span> </div><br /><br /> <div class="formfield"> Enter a User Name: <input id="user" name="user" type="text" size="12" onblur="validateNonEmpty(this, document.getElementById('user_help'))" /> <span id="user_help" class="help"></span> </div><br /><br /> <div class="formfield"> Enter your password (4 to 7 letters and/or numbers): <input id="pw" name="pw" type="text" size="7" onblur="validateNonEmpty(this, document.getElementById('pass_help'))" /> <span id="pass_help" class="help"></span> </div><br /><br /> <input type="button" value="Save" onClick="placeOrder(this.form);" /> </form> <div id="footer" align="center"> <br /><br /> <a href="mod1.html" title="iRock">iRock</a> <a href="mod2dq.html" title="Mod 2 DQ">Mod 2 DQ</a> <a href="mod2.html" title="Order Form">Order Form</a> <a href="index.html" title="Home">Home</a> <a href="mod4.html" title="SFA">SFA</a> <a href="mod5.html" title="Vendor Showcase!">Vendor Showcase!</a> <a href="mod6.html" title="Vendor Showcase Redux">Vendor Showcase Redux</a> <br /> <a href="mod7.html" title="New Customer Account Form">New Customer Account Form</a> <a href="mod8.html" title="Mod 8">Mod 8</a> <a href="mod9.html" title="Mod 9">Mod 9</a> <a href="mod10.html" title="Mod 10">Mod 10</a> <a href="mod11.html" title="Mod 11">Mod 11</a> <a href="mod12.html" title="Mod 12">Mod 12</a> <a href="mod13.html" title="Mod 13">Mod 13</a> <a href="mod14.html" title="Mod 14">Mod 14</a> <br /><br /> <p align="center">Copyright © 2010 WEB 200 Labs Last updated: February 2010<br /> <a href="mailto:SunnyOne99@hotmail.com">Sue Raymond @SunnyOne99@hotmail.com</a></p> <p> <a href="http://validator.w3.org/check?uri=referer"><img style="border:0" src="http://www.w3.org/Icons/valid-xhtml10-blue" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a> <a href="http://jigsaw.w3.org/css-validator/check/referer"> <img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" /></a> </p> </div></div> </body> </html> Hi, so I have this function: Code: function centerZoom() { var bounds = new google.maps.LatLngBounds(); for (var i = 0; i < gmarkers.length; i++) { if (!gmarkers[i].isHidden()) { var point = gmarkers[i].getPoint(); bounds.extend(point); } map.setZoom(map.getBoundsZoomLevel(bounds)); map.setCenter(bounds.getCenter()); } } which I call he Code: for (var j = 0; j < gmarkers.length; j++) { var str=gmarkers[j].myname.toLowerCase(); var patt1=inp; if (str.match(patt1)) { found = true; gmarkers[j].show(); centerZoom(); } which I thought was pretty straightforward, but I keep getting a "centerZoom is undefined" message. The only place I don't get that is if I take it out of the initialize sequence, but it doesn't work then anyway (and from what I understand, being that it contains var bounds = new... it has to go in initialize. Here's the rest of the page, if anybody has any ideas I am using a checkbox to turn on and off some labels on a line on a google map, which is working fine if the line is already drawn, using this function: Code: function distboxclick(labelsbox) { if (labelsbox.checked) { for (var i=0; i<distmarkers.length; i++) { if (distmarkers[i].mLabel != null) distmarkers[i].mLabel.show(); } } else { for (var i=0; i<distmarkers.length; i++) { if (distmarkers[i].mLabel != null) distmarkers[i].mLabel.hide(); } } } but the thing is that I want the labels to be turned off to begin with and switched on if the box is checked. Which is also fine, using this snippet: Code: if (prevMarker){ var dist = getSegmentDistance(prevMarker.mMarker, distmarker); var label = new ELabel(point, dist, "labelstyle", new GSize(10,-15)); distmarkers[numMarkers-1].mLabel = label; distlabels.push(label); map.addOverlay(label); label.hide(); drawOverlay(); } but what I am trying to do now is make sure that if the box is checked before the line starts to be drawn then the labels will come up straight away. So I figured all I had to do was add in the following to the above: Code: if (labelsbox.checked){ label.show(); } else { label.hide(); } and pass the labelsbox variable to the function where that is all happening. But instead I get a "labelsbox is undefined" error... If I take that if statement out I see that labelsbox is defined, but that doesn't really help. I guess I'm putting things in the wrong order or something, but I'm kind of baffled. You can see my test page here. Thanks in advance for any suggestions. Hi All, In one of my php page I have a form where I am displaying a table. The First row is having the drop down and the second row is a text field. Now the problem is that based on the drop down value choosed I have to set some field in text field. For this I am calling a javascript function but when I am trying to set the value in the text field which is still not into picture when this function is called it is showing the error that the field is not defined. Can Anyone tell how I can get access to a field which is yet not defined. I even tried to make a hidden field before drop down and tried to set some value for that still I am facing the same problem. Can anyone help me out ... Hi, I am having 1 JS file 'common.js', which has 2 functions: func1(); func2(); and 2 PHP files: file1 and file2. I am calling func1() from file1 (<html><body onload="javascript:func1()"...) and initializing some global variables in func1. Then i am calling func2() from file2 and reading those variables, but those i am getting undefined. Is it because the variables were initialized in a function which was called by some file, that i am not able to access in a function called by another file, like a scope problem? I thought since both the functions are in same file, the global variables in that file are accessible to all functions in that file. Please help! Thanks! First time posting, I hope I'm doing this right. I'm having problems with the following code, it is just a simple form but I keep getting an error message saying " my elementId is undefiened and I can not find out where I messed up. 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> <title>Form Help</title> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> <script type="text/javascript"> /* <![CDATA[ */ function showHelp(elementID) { var curElement = document.getElementById(elementId); var helpElement = document.getElementById("box"); switch (elementId) { case "username": helpElement.innerHTML = "Enter a unique user name that is between 5 and 12 characters. "; break; case "password": helpElement.innerHTML = "Enter a password between 6 and 10 characters tht contains both upper and lowercae letters an at least one numeric character. "; break; case "password_confirm": helpElement.innerHTML = "Confirm your selected password. "; break; case "challenge": helpElement.innerHTML = "Enter your mother's maiden name. This value will be used to confirm your identity in the event that you forgot your password. "; break; } helpElement.innerHTML +="<a href=''onclick=\"document.getElementById('box').style.visibility = 'hidden';return false;\">Close</a>"; document.getElementById("box").style.visibility = "visible"; document.getElementById("box").style.left = curElement.offsetWidth + 20 + "px"; document.getElementById("box").style.top = curElement.offsetTop + "px"; } /* ]]> */ </script> </head> <body> <h1>Form Help</h1> <form action="" method="get" enctype="application/x-www-form-urlencoded"> <p><strong>User Name</strong><br /> <input type="text" id="username" size="50" onmouseover="this.style.cursor='help'" onclick="showHelp(this.id)" /></p> <p><strong>Password</strong><br /> <input type="password" id="password" size="50" onmouseover="this.style.cursor='help'" onclick="showHelp(this.id)" /></p> <p><strong>Confirm Password</strong><br /> <input type="password" id="password_confirm" size="50" onmouseover="this.style.cursor='help'" onclick="showHelp(this.id)" /></p> <p><strong>What is your mother's maden name?</strong><br /> <input type="password" id="challenge" size="50" onmouseover="this.style.cursor='help'" onclick="showHelp(this.id)" /></p> </form> <div id="box" style="position: absolute; visibility: hidden; width: 250px; background-color:#C0FFFF; font: Comic Sans MS; color: #A00000;border:1px dashed #D00000"></div> </body> </html> |