JavaScript - Help Fixing Errors In Ie
I have the following code for determining 30 year amortization for fha and conventional loans:
Code: function calc(){ var alrt=""; if (document.getElementById("down").value==""){ alrt+="Down Payment\n"; } if (!document.getElementById("con").checked && !document.getElementById("fha").checked){ alrt+="Loan Type"; } if (alrt!=""){ alert("You Must Fill Out the Following Fields:\n"+alrt); } else { doAmb(); } } function doAmb(){ var pur=purchasePrice; var down=eval(document.getElementById("down").value); if (document.getElementById("type").selectedIndex==1){ downPay=down*.01; downPay=downPay*pur; } else { downPay=down; } var pay=pur-downPay; if (document.getElementById("fha").checked){ pay=pay*(1.0225); } amt=getPayment(pay,360,interestRate); writeData(pur,downPay,amt); } function getPayment(a,n,p) { var acc=0; var base = 1 + p/1200; for (i=1;i<=n;i++) { acc += Math.pow(base,-i); } return a/acc; } function writeData(pp,dp,mp){ document.getElementById("purc").innerHTML=Math.round(pp*100)/100; document.getElementById("mon").innerHTML=Math.round(mp*100)/100; document.getElementById("downP").innerHTML=Math.round(dp*100)/100+" ("+(Math.round(((dp/pp)*100)*100)/100)+"%)"; document.getElementById("loan").innerHTML=Math.round((pp-dp)*100)/100; document.getElementById("inter").innerHTML=interestRate; document.getElementById("ins").innerHTML=insurance; document.getElementById("tax").innerHTML=tax; document.getElementById("tot").innerHTML=Math.round((tax+insurance+mp)*100)/100; document.getElementById("sptype").innerHTML=((document.getElementById("con").checked)?"Conventional": "FHA"); document.getElementById("inputArea").style.display="none"; document.getElementById("outputArea").style.display="block"; } function showIn(){ document.getElementById("cover").style.display="block"; document.getElementById("inputArea").style.display="block"; } It works 100% perfectly in Firefox, but in Internet Explorer, it won't do anything. Also, I know there may be some missing variables, those are in a separate JS file. Edit: Also, just discovered that it works fine when used inline, but loaded from an external file, it returns an "Invalid Character" error. Similar Tutorialsis there any way to fix the position of a draggable div in a table which is having fixed width and height??
I've been working on this code and I need help fixing it. <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Dog</title> <script> var fido = { name: "Fido", weight: 20.2, age: 4, breed: "mixed", activity: "fetch balls" }; var gleen = { name: "Gleen", weight: 15, age: 5, breed: "PitBull", activity: "fetch balls" }; var bensy = { name: "Bensy", weight: 25, age: 10, breed: "Terrier", activity: "Getting massaged" }; var lily = { name: "Lily", weight: 25, age: 20, breed: "Great Dane", activity: "Resting" }; var ben = { name: "Ben", weight: 30, age: 2, breed: "Mostiff", activity: "running" }; function bark(dog) { if (dog.weight > 20) { bark = "WOOF WOOF"; } else { bark = "woof woof"; } } var barks = bark(ben) function doggies(dogs, dogz) { if (dogs) { console.log (dogz.name + " " + "says" + " " + bark + " " + "give me" + " " + dogz.activity); } else { console.log (dogz.name + " " + "says" + " " + bark + " " + "give me" + " " + dogz.activity); } } doggies(fido, fido); doggies(gleen, gleen); doggies(bensy, bensy); doggies(lily, lily); doggies(ben, ben); </script> </head> <body></body> </html> It will work on console, and every body will say WOOF WOOF ( in uppercase). Except that gleen should say woof woof (in lowercase) since he weighs less then 20 pounds. What did I do wrong in my code? Hi, I'm very much a newbie regaridng javascript and have been looking around and experimenting and have created a javascript although it does not function(Javascript code below), can someone help me fix it? Many Thanks. function gotoURL(){ var newURL = document.GotoForm.theURL.value if (newURL == "info1" || "info2" || "info3" || "info4" || "info 5"){ document.location.href=newURL+".html" }else{ alert("You entered an invalid value"); }} Hi, I am a small problem with the combo boxes in my web page.I have created a web search portal for travelling in that i have used combo boxes for selecting the no.of.passengers (Adults, Childs & Infants) along with the ages of the children.Take for example i have a hotel search page in that i have used combo box to select the no.of.rooms. And i have kept the same concept in selection of passengers too(i.e., when u select Room count as '2' there will two rows displayed separately for choosing adults & child) and when u choose child as '1' another combo box will appear to select for 1 child this is unique for each rooms. Now i can able to do the first part clearly that is when select room count the rows are displaying as per the no. But when i select for child the age combo box is coming same for all the rooms and not as unique (separate) for each room. Can anyone help me to fix this problem! Thanks, Hi,Im a student studying web design and I am stuck with my JavaScript Login code. I want my code to be able to log a user in if they have the correct username and password fields.however,if the password or username is wrong i would like to display a message in the label that says 'not valid' if they do not put anything into the username or password field,the label should read 'field cannot be empty.' this is what i have so far.im sure i have done something wrong.thank you in advance function validate() { var login="true"; document.getElementById("lblFnameVal").innerHTML=""; var checkForX = document.getElementById("fname").value; document.getElementById("lblpass").innerHTML=""; var passw = document.getElementById("fpass").value; if(document.getElementById('checkForX').value.length==0) { document.getElementById("lblFnameVal").innerHTML="username cannot be empty"; document.getElementById("lblFnameVal").style.color="red"; login="false"; } else if(document.getElementById('passw').value.length==0) { document.getElementById("lblFnameVal").innerHTML="username cannot be empty"; document.getElementById("lblFnameVal").style.color="red"; login="false"; } else (checkForX != "username" ) { document.getElementById("lblFnameVal").innerHTML="not valid"; document.getElementById("lblFnameVal").style.color="red"; login="false"; } else if(passw !="password") { document.getElementById("lblpass").innerHTML="not valid"; document.getElementById("lblpass").style.color="red"; login="false"; } if(login =="true" ) { document.getElementById("mypassForm").submit() } } I've ran the entire code through a javascript debugger a few times and I believe I weeded out the obvious errors. Also I believe I fixed some of the more hidden errors that one can't find with even the best debuggers.. Still it doesn't perform like it should? I found other scripts that do the same thing, but it defeats the purpose of me fixing it if I just write up a new code, even if it's easier. What make it hard for me to digest is it is somewhat complex compared to other codes that do the exact same thing. Any help? Also attached a zip file for those who want to see it externally.. Code section Code: <script type="text/javascript"> /* <![CDATA[ */ var sortItems = 1; function move(sourceList,targetList) { for(var i=0; i<sourceList.options.length; i++) { if(sourceList.options[i].selected && sourceList.options[i].value != "") { var no = new Option(); no.value = sourceList.options[i].value; no.text = sourceList.options[i].text; targetList.options[targetList.options.length] = yes; sourceList.options[i].value = ""; sourceList.options[i].text = ""; } } moveUp(sourceList); if (sortItems) doSort(targetList); } function moveUp(curOptionList) { for(var i=0; i<curOptionList.options.length; i++) { if(curOptionList.options[i].value == "") { for(var j=i; j<curOptionList.options.length-1; j++) { curOptionList.options[j].value = curOptionList.options[j+1].value; curOptionList.options[j].text = curOptionList.options[j+1].text; } var curLine = 0; break; } } if(curLine < curOptionList.options.length) { curOptionList.options.length -= 1; moveUp(curOptionList); } } function doSort(curOptionList) { var newOptions = new Array(); var tempOptions = new Object(); for(var i=0; i<curOptionList.options.length; i++) { newoptions[0] = curOptionList.options[0]; } for(var x=0; x<newOptions.length-1; x++) { for(var y=(x+1); y<newOptions.length; y++) { if(newOptions[x].text > newOptions[y].text) { tempOptions = newOptions[x].text; newOptions[x].text = newOptions[y].text; newOptions[y].text = tempOptions; tempOptions = newOptions[x].value; newOptions[x].value = newOptions[y].value; newOptions[y].value = tempOptions; } } } for(var i=0; i<curOptionList.options.length; i++) { curOptionList.options[i].value = newoptions[i].value; curOptionList.options[i].text = newoptions[i].text; } } /* ]]> */ </script> Form section Code: <body> <form action="" method="get" enctype="application/x-www-form-urlencoded"> <table border="0"> <tr> <td><select multiple="multiple" size="5" name="list1"> <option value="11">iPod Nano</option> <option value="12">iPod Shuffle</option> <option value="13">iPod Classic</option> </select></td> <td> <input type="button" value=" ›› " onclick="move(list1,list2)" name="B1" /> <br /> <input type="button" value=" ‹‹ " onclick="move(list2,list1)" name="B2" /> </td> <td><select multiple="multiple" size="5" name="list2"> <option value="21">MacBook</option> <option value="22">MacBook Pro</option> <option value="23">MacBook Air</option> </select></td> </tr> </table> </form> </body> </html> Hey guys. This is vague because I dont know what exactly to tell you but please reply with me so I can fix this. I want to add something to my forum. Specifically, I want to add a HTML and Picture button for when you go to reply. Like posting an article here, there are also these options (font, alignment, insert image) I do not know how to achieve this but shouldnt be too hard. Here are the two sources you will need to look through to help me fix the forum. http://neoweather.com/FWFORUM.JS http://static.websimages.com/JS/fw.js THANKS Hey guys. I want to add something to my forum. Specifically, I want to add a HTML and Picture button for when you go to reply. Like posting an article here, there are also these options (font, alignment, insert image) I do not know how to achieve this but shouldnt be too hard. Here are the two sources you will need to look through to help me fix the forum. http://neoweather.com/FWFORUM.JS http://static.websimages.com/JS/fw.js THANKS Hi I am doing validation on a form, but instead of throwing an alert on empty fields I want to highlight those fields indicating error. if all are empty, then i would like to show only 1 generalized error message "Pls. fill the highlighted textboxes.". how do i do this and thanks in advance. i get this error when ever i try to process the form: There was a SyntaxError: Unexpected token < error due to an parsererror condition. Javacsipt/jquery: $(document).ready(function(){ $("#slide").click(function(){ $("#inner-wrapper").slideToggle(); }); $('form #response').hide(); $('#submit').click(function(e){ e.preventDefault(); var valid = ''; var required = ' is required'; var name = $('form #name').val(); var email = $('form #email').val(); var fname = $('form #fname').val(); var femail = $('form #femail').val(); var message = $('form #message').val(); var honeypot = $('form #honeypot').val(); var humancheck = $('form #humancheck').val(); //Error checking if (name == '' || name.length <=2) { valid = '<p>Your name' + required + '</p>'; } if (!email.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/)) { valid += '<p>Your email' + required + '</p>'; } if (fname == '' || fname.length <=2) { valid += '<p>Your friend\'s name' + required + '</p>'; } if (!femail.match(/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/)) { valid += '<p>Your friend\'s email' + required + '</p>'; } if (message == '' || message.length <=5) { valid += '<p>A message' + required + '</p>'; } if (honeypot != 'http://') { valid += '<p><center>Spambots are not allowed.</center></p>'; } if (humancheck != '') { valid += '<p><center>A human user' + required + '</center></p>'; } if (valid != '') { $('form #response').removeClass().addClass('error') .html('<strong>Please correct the errors below.</strong>' + valid).fadeIn('2000'); }else { $('form #response').removeClass().addClass('processing').html('<center>Working...</center>').fadeIn('2000'); var formData = $('form').serialize(); submitForm(formData); } }); }); function submitForm(formData) { $.ajax({ type: 'POST', url: 'emailfriend.php', data: formData, dataType: 'json', cache: false, timeout: 7000, success: function(data) { $('form #response').removeClass().addClass((data.error === true) ? 'error' : 'success') .html(data.msg).fadeIn('fast'); if ($('form #response').hasClass('success')) { setTimeout("$('form #response').fadeOut('slow')", 5000); } }, error: function(XMLHttpRequest, textStatus, errorThrown) { $('form #response').removeClass().addClass('error') .html('<p>There was a <strong>' + errorThrown + '</strong> error due to an <strong>' + textStatus + '</strong> condition.</p>').fadeIn('fast'); }, complete: function(XMLHttpRequest, status) { $('form')[0].reset(); } }); }; php file PHP Code: <?php error_reporting(E_ALL ^ E_NOTICE); sleep(3); $name = stripslashes($_POST[name]); $email = stripslashes($_POST[email]); $fname = stripslashes($_POST[fname]); $femail = stripslashes($_POST[femail]); $message = stripslashes($_POST[message]); $honeypot = $_POST[honeypot]; $humancheck = $_POST[humancheck]; if ($honeypot == 'http://' && empty($humancheck)) { $error_msg = ''; $reg_exp = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/"; if (!preg_match($reg_exp, $email)) { $error_msg .= "<p>A valid email is required</p>"; } if (!preg_match($reg_exp, $femail)) { $error_msg .= "<p>A valid email is required</p>"; } if (empty($name)) { $error_msg .= "<p/>Please provide your name</p>"; } if (empty($fname)) { $error_msg .= "<p/>Please provide your name</p>"; } if (empty($message)) { $error_msg .= "<p>A message is required.</p>"; } if (!empty($error_msg)) { $return['error'] = true; $return['msg'] = "<h3>Oops! Looks like you missed a few fields.</h3>".$error_msg; echo json_encode($return); exit(); }else { $return['error'] = false; $ref=@$HTTP_REFERER; /////Message at the top of the page showing the url//// $header_message = "Hi $fname \n Your friend $name requested you to visit this page at \n $ref \n"; /// Body message prepared with the message entered by the user //// $body_message =$header_message."\n".$message."\n"; // IP address of visitor is added to message, you can remove it if not required.// $body_message .="\n Sent from http://www.separatethescams.com"; //// Mail posting part starts here ///////// $headers=""; //$headers = "Content-Type: text/html; charset=iso-8859-1\n".$headers; // Un comment the above line to send mail in html format $headers4=$email; // Change this to change from address $headers.="Reply-to: $headers4\n"; $headers .= "From: $headers4\n"; $headers .= "Errors-to: $headers4\n"; $subject="$name visit this site!"; mail($femail,$subject,$body_message,$headers); $return['msg'] = " <b><p><center>Thanks for spreading the word! :) " . "<font color='red'>" .$name . "</font>" . " </p>" . "</b>" . "</center>"; echo json_encode($return); } }else { $return['error'] = true; $return['msg'] = "<h3><center>0ops there was a problem submitting the data. Please try again!</center></h3>"; echo json_encode($return); } ?> html file <html> <head> <link rel="stylesheet" href="ajaxform/form.css" type="text/css" media="screen"/> </head> <body> <div id="wrapper"> <h3 id="slide">Email This Page To a Friend</h3> <hr></hr> <div id="inner-wrapper"> <form id="my_form" action="ajaxform/emailfriend.php" method="post"> <div id="response"><!--This will hold error message and response from server. --></div> <div class="inputs"> <p> <label>Name   ; </label> <input name="name" type="text" placeholder="Your Name" class="required" id="name" size="30" /> </p> </div> <div class="inputs"> <p> <label>Email &nbs p; </label> <input name="email" type="text" placeholder="Your Email" class="required" id="email" size="30" /> </p> </div> <div class="inputs"> <p> <label>Friend's Name </label> <input name="fname" type="text" placeholder="Friend's Name" class="required" id="fname" size="30" /> </p> </div> <div class="inputs"> <p> <label>Friend's Email </label> <input name="femail" type="text" placeholder="Friend's Email" class="required" id="femail" size="30" /> </p> </div> <div class="inputs"> <p> <label id="msg">Message </label> <textarea name="message" cols="24" rows="5"type="text" placeholder="Message To Friend" class="required" id="message"></textarea> </p> </div> <div class="button"> <input name="submit" type="submit" id="submit" value="EMAIL PAGE" /> </div> <div class="inputs"> <input type="hidden" name="honeypot" id="honeypot" value="http://" /> <input type="hidden" name="humancheck" id="humancheck" class="clear" value="" /> </div> </form> </div> <!-- inner-wrapper end --> </div> <script type="text/javascript" src=" https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script type="text/javascript" src="ajaxform/ajax_submit.js"></script> </body> </html> here is the link where the problem persist http://www.ornusweb.com/what_we_done.html I have mixed 2 scripts the light box script(lightbox.js) and scroller script(scriptaculous.js) the page only works with ie and in other browsers it opens as an image(light box wont work) the errors say 1st error> uncaught script.aculo.us requires the prototype javaScript frame work >1.4.0 scriptaculous.load (anonymous function) 2 error > uncaught typeErrorbject function object(){[native code]} has no method 'extends' (anonymous function) can some one help me solve these problem's If you go to: http://www.five-nine.net/index2/index.html and click on "Go Ahead what ..... info@five-nine.net" And try to submit the form, it will work in every browser except IE6, IE7, & IE9, (I don't know why IE8 is so different than the rest but w/e)... However I don't see any errors on in the JavaScript. Does anyone know why this would happen in just those three browsers? Hey guys, Working on a large project. Ive created a form that when an anchor is clicked it calls the following javascript. This code executes fine in FF and creates a new select box, input box, and delete anchor. When i attempt this code in IE 8, an error occurs. The error message below and referes to the lines in which i have used the newField array. Code: <script type="text/javascript"> var counter = 0; function moreFields() { var newFields = document.getElementById('rowline').cloneNode(true); var insertHere = document.getElementById('inputgroup'); var newField = newFields.childNodes; counter = document.getElementsByTagName('select').length; newField[2].name = 'item' + counter; counter = document.getElementsByTagName('input').length; newField[5].name = 'amount' + counter; newField[7].style.display = 'block'; insertHere.parentNode.insertBefore(newFields,insertHere); } </script> Error: Object doesn't support this property or method Im guessing this refers to the attempt to use .name/.style . Does anyone know why this is the case or an alternative way to do this? Thanks. Matthew King The validator showed up these errors on my site. They are from a script, but I know very limited javascript to correct it, to me it seems to be OK. 1. Line 15, Column 23: character "<" is the first character of a delimiter but occurred as data for (var i = 0; i < d.length; ++i) { This message may appear in several cases: * You tried to include the "<" character in your page: you should escape it as "<" * You used an unescaped ampersand "&": this may be valid in some contexts, but it is recommended to use "&", which is always safe. * Another possibility is that you forgot to close quotes in a previous tag. 2. Error Line 15, Column 23: StartTag: invalid element name for (var i = 0; i < d.length; ++i) { Code: <script type="text/javascript"> window.onload = function() { if (!NiftyCheck()) { return; } Rounded("div#nifty", "#666", "#FFF", 30, 30); } function adjustRadius() { d = getElementsBySelector("div.rounded"); for (var i = 0; i < d.length; ++i) { d[i].parentNode.removeChild(d[i]); } var x = document.getElementById("radiusx").value; var y = document.getElementById("radiusy").value; Rounded("div#nifty", "#666", "#FFF", x, y); return false; } </script> Does anyone know why these errors are coming up on the WC3? Hi. I've just finished up a web design I've been working on and of course it looks and works great in FF, but has problems in IE. My question is, how do you see what's wrong in IE? I know how to fix the html/css but how do I see what's going wrong with the javascript and php? Is there link in IE where I can see the errors? Thanks in advance. I've tried a couple of different scripts, and I'm getting the same result, so I know I must just be missing something. I'm very new to this, so I'm not figuring it out. I want a text box to show the results of an increment counter. Every time I click a button, the number in the text box increments by one. I know it sounds simple, but it's not working. Help? My code is below: Code: <style type = "text/css"> .tbsize { width: 30px; border: 3px; padding: 10px } </style> <script type="text/javascript"> var i=0; function increase() { ++i; } </script> </head> <body> <div id = "tbsize" class = "tbsize"> <form onsubmit = "return false" action = ""> <table> <td><input type = "text" id = "addone" /></td> <td><input type = "submit" value = "Click to add One" onclick="increase()"></td> </table> </form> </div> </body> </script> is there anyway to set my code in javascript to ignore errors I have an error that comes up on ie but everything workes fine and i can't find the source of the error -- can i tell the browser to ignore it? ****ING FORUM PIECE OF ****, just wrote a whole post about my error and got taken to login when I clicked submit and the post is gone now, great, thanks for caching the tags and the title, really needed those...................flsdkjflsdkfjsd
|