JavaScript - Map Is Undefined
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> Similar TutorialsI 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()? 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? 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 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 ?? 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> 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> 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 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. 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> 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> 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.. I have checkbox and I need to get his value. I create function for checkbox if checkbox is clicked it is true then the checkbox value is H else W. Code: function chk(){ if(document.getElementById('H').checked==true){ var H = document.getElementById('H'). value = H; } else if(document.getElementById('H').checked==false){ var H = document.getElementById('H'). value = W; } } and I have function for save : Code: function ApproveLeaveOP(){ var H = document.getElementById('H').value; document.sampleform.action="AddLeave.php?H="+H; document.sampleform.submit(); } <input type="checkbox" name="H" id="H" value="" onclick="chk()"> I don't know how can I add value to the checkbox if I click the value will be H if not the value is W. I am new in using checkbox. Thank you so much.. I'm trying to get this assignment done for class. I've spent 3 hours on this part alone. These aren't supposed to be that hard. However, it keeps saying that the variable toppings is undefined. Why is it doing that? Especially since it can find the values when I tell it to print them out with an alert. Yet it won't execute the final part where I go to the confirm. Code: <html> <head> <script> function confirm(theForm) { var selectedItems = ""; var i = 0; for(i =0; i < theForm.toppings.length; i++) { alert(theForm.toppings[i].value); if (theForm.toppings[i].checked==true) { selectedItems = selectedItems + "\n" + theForm.toppings[i].value; } } var r = confirm("You have selected " + selectedItems + "\n" + "Is this correct?"); if (r == true) alert("Ok"); } </script> </head> <body> <form name="form"> <label for="toppings"> <BR><Select name="toppings" MULTIPLE id="toppings"> <OPTION SELECTED> Cheese <OPTION> Pepperoni <OPTION > Onions <OPTION> Sausage <OPTION> Olives </SELECT> <input type="button" value="Confirm selection." onClick="confirm(this.form)"> </form> </body> </html> Never mind, it was because I had named the function "confirm()". A really dumb move on my part. Hello, I'm working on web apps for a company and unfortunately the websites work in Mozilla, chrom and IE9 but not in IE8. In IE8 the error message "undefined is null or not an object" is pointing to this line: temp = val.replace(/-/g, "/"); That line is inside a function. I'm not sure how to troubleshoot this...any help would be appreciated. We use Microsoft Dynamics CRM, which allows you to use JavaScript on your forms (as it's a web-based solution). I created my very first, very simple script, which just checks to see if a Field is popluated, and if it is, a pop-up window appears. However, I keep getting this error: "Error:'Form_OnLoad' is undefined" This is my Code Code: // ------------- // // Microsoft Dynamics CRM 2011 JavaScript // Name: Account Pop-up // Modified: 29 October 2014 // ------------- // function Form_OnLoad() { GetValueFromCRMField(); } function GetValueFromCRMField() { //Get the Value of Alert and Set to a Variable var getSubject = Xrm.Page.getAttribute("bitc_Alert").getValue(); // If the Subject Field is Populated if (getSubject == true) //Pop-up Window in CRM alert(getSubject); } Can anyone see what I've done wrong. I must have scanned this a dozen times, and I'm going cross-eyed. Thanks in advance for any insight or help. Brian Hi, I'm trying to use a javascript tabstrip script called aptabs, which uses prototype.js. However, prototype.js won't load properly, because the following error occurs in prototype.js: destination is undefined on the following line (3042): destination[property] = value.methodize(); The function this line is in is: Code: function copy(methods, destination, onlyIfAbsent) { onlyIfAbsent = onlyIfAbsent || false; for (var property in methods) { var value = methods[property]; if (!Object.isFunction(value)) continue; if (!onlyIfAbsent || !(property in destination)) destination[property] = value.methodize(); } } I've tried using versions 1.6.0 all the way up to 1.6.1, but I still get the same error. Can someone suggest what this error could be caused by and possible fixes? Debbie Hi, This is my first post while learning Javascript and jQuery as total noob. I have something like this: Code: var desc = "This is your title and here is even more that might be added so that we can get at least 60 characters or so"; var desc = desc.trim().substring(0, 40).split(" ").slice(0, -1).join(" ") + "...more"; alert(shortText ); It is actually being used on a page that calls a description from a MySQL table, but this example fails in exactly the same manner. Although FF and other browsers successfully initiate the script with errors, but IE loops endlessly and freezes up. FireBug reports "reference to undefined property a[d]". Using jQuery 1.6.2. I'm not really sure what property is undefined here and how this can work without freezing IE. Thanks in advance for any help! AJ |