Simple Calculation - Error On Function Call

Aug 15, 2011

I have written the following javascript code which makes a simple calculation and writes between the <span> tags using Inner HTML

My code is:
Code:
<html><head>
<script type="text/javascript">
function hesapla() {
kredimiktari = document.hesapla.miktar.value
kredivadesi = document.hesapla.vade.value;
faiz = document.hesapla.faiz.value;
ayliktaksit1 = (kredimiktari * faiz) / kredivadesi;
geriodeme1 = kredimiktari * faiz;
document.getElementById('ayliktaksit').innerHTML = "<strong>Taksit / Ay :</strong>" + ayliktaksit1;
document.getElementById('geriodeme').innerHTML = "<strong>Taksit / Ay :</strong>" + geriodeme1;}
</script></head><body>
<form name="hesapla">

<input type="text" name="miktar" value="Kredi Miktarı" onfocus = "if (this.value == 'Kredi Miktarı') this.value = '';" onblur = "if (this.value == '') this.value = 'Kredi Miktarı';" />
<input type="text" name="vade" value="Kredi Vadesi" onfocus = "if (this.value == 'Kredi Vadesi') this.value = '';" onblur = "if (this.value == '') this.value = 'Kredi Vadesi';" />

<input type="text" name="faiz" value="Faiz Oranı" onfocus = "if (this.value == 'Faiz Oranı') this.value = '';" onblur = "if (this.value == '') this.value = 'Faiz Oranı';" />
<div id="gosterim"><span id="ayliktaksit"></span><span id="geriodeme"></span></div>
<input type='button' value='Hesapla' onClick='hesapla()'><br><br>
<img src="images/dot2.png" width="180" height="2" alt="dot"/>
</form></body></html>

I am really confused as similar code on Tizag web site works fine.
Code:
<script type="text/javascript">
function changeText(){
document.getElementById('boldStuff').innerHTML = 'Fred Flinstone';
}</script>
<p>Welcome to the site <b id='boldStuff'>dude</b> </p>
<input type='button' onclick='changeText()' value='Change Text'/>

View 2 Replies


ADVERTISEMENT

Simple Listbox OPTIONAL Value Calculation ?

Mar 14, 2009

Trying to figure out a problem with the "Optional" values in a list box so I am going to keep it as simple as I can..

I am trying to calculate the optional value of a list box in stead of programming it the long way around.

I created a list box with several peoples names, like John, Sue, and Mary.

I have assigned each name a numeric "optional" values

I know the code in the list box should be:

Normally, I would code this along the lines of:

But I want to figure out how to select the Optional Value from the list, and multiply it by time instead of doing the SELECTEDNAMELISTBOX=="John" route..

View 4 Replies View Related

Simple Calculation Doesn't Work

Nov 23, 2010

I have an input for Fahrenheit in degrees, then a button to start the calculations, then an input box for the result. But the result stays empty. where my Javascript code went wrong? I am modifying someone else's code form the Internet,I am guessing at how it works. [code]

View 4 Replies View Related

Changing Calculation In Simple Interest Calculator

Aug 10, 2010

The exercise problem is to "MODIFY the code in the "calculate_click" event so interest is added to future value just once each year for the number of years that they were entered by the user". The calculation as you see it below assumes an amount is invested MONTHLY (not just once), and the interest is calculated accordingly. This is what I think the problem is trying to calculate: using a $100 one time investment at 10% interest (compounded once annually) for one year = $110 as the future value. For two years, the future value should equal $121 (110 + (110*.10)). Okay, if my math is wrong, let me know. This is what I'm trying to get it to match to.

I have been able to modify the calculate_click function to compound the interest annually (it does it monthly now). Cool. I cannot get it to stop adding $100 annually. See my math above? I think that's the answer. My manipulation of the code yields $110 for the first year, $231 for the second year, etc. The $231 is incorrect cuz it adds an extra $100. See, this is a simple interest calculator I can't figure out! The original code is below that calculates the investment as a monthly investment as opposed to one-time. To avoid confusion, I did not include any of my modifications. But yeah. I know that the major culprit is how the "for" loop is being executed. I've highlighted where I think the code needs to be changed, but I haven't changed it here. Note the first function is a shortcut to execute getElementbyID.

The Code:
var $ = function (id) {
return document.getElementById(id);
} var calculate_click = function () {
var investment = parseFloat( $("investment").value );
var annualRate = parseFloat( $("rate").value );
var years = parseInt( $("years").value );
$("futureValue").value = ""; .....

View 2 Replies View Related

Call Function Only If Another Function Does Not Return Error?

Feb 14, 2011

I'm trying to "progressively enhance" one of my surveys using javascript. Basically, I have rating scales that make use of radio buttons as each point on the scale. Each radio button occupies its own cell in a table. I wrote some functions that will highlight cells on mouseover in a color corresponding to its position on the scale (e.g. the lowest point is red, the midpoint is yellow, the highest point is green). When a radio button is clicked, the background of the button's cell and preceding cells in the same row will be colored accordingly. The functions are working well in FireFox and Chrome (I just have to add a few lines using the addEvent function to make it compatible with IE).

The effect looks a lot nicer when I add a function that makes the visibility of the radio buttons hidden.

However, I want to make sure that there is a fallback option in case the functions that color the cells don't work for whatever reason. I would not want the radio buttons hidden in this case.

Is there a method whereby I can call the "hideRadiobuttons" function only if the other functions are successfully executed?

View 8 Replies View Related

Function Runs Once, Error On Second Call?

Mar 8, 2010

I have a function which is called twice. It allows the elements of an array to be set to a different color, successively:

function ln8 (arrayA,color,current) {
var arrayB=(typeof arrayA == 'string')? arrayA.split(',') : arrayA;
var line = document.getElementById(arrayB[current]);

[code]....

View 8 Replies View Related

Fatal Error Call To Undefined Function PHP

Mar 15, 2011

I know I shouldn't be having this problem at this stage. But what have I done wrong?I have my main page, I have my onload page and in that onload page I call a function:And then I get the error message:Fatal error: Call to undefined function OpenChat.Needless to say I am trying to create an instant chat.

View 26 Replies View Related

JQuery :: Calculation Plugin - How To Use Live Function

Oct 20, 2009

I am currently working on a project where I am using the jQuery Calculation plugin [URL] to do some math functions in a dynamic form, the issue is that when a new set of fields is created the calculation script only pulls data from the ones there when the page loaded, I am fairly certain that what I need to do is use the live function, however I am not very familiar with it and still learning. My jQuery for the plugin is :
$("input[name^=emem]").sum("keyup", "#totalMem");

View 1 Replies View Related

Getting Nan Error With Simple Math

Mar 5, 2010

why I am getting Nan

<script type="text/javascript">
var num1;
var num2;
var num3;

[Code]....

View 3 Replies View Related

Simple Error Checking

Jan 27, 2006

Sorry this will be an ignorant question I know, but I'm just trying to implement some quick JS in my form to check if the fields were filled in:


function check_form() {

if (survey.form_firstname.value == "") {
firstname_error = "-Please enter your first name
";
}

if (survey.form_lastname.value == "") {
lastname_error = "-Please enter your last name
";
}

if (survey.form_phone.value == "") {
phone_error = "-Please enter your phone number
";
}

if (survey.form_email.value == "") {
email_error = "-Please enter your email
";
}

if (!survey.form_agree.checked) {
agree_error = "-You must be over 18 and provide accurate information
";
}

errors = firstname_error + lastname_error + phone_error + email_error + agree_error;

if(!errors) {
return true;
} else {
alert("There were errors:
" + errors);
delete firstname_error;
delete lastname_error;
delete phone_error;
delete email_error;
delete agree_error;
delete errors;
return false;
}
}

It only seems to work if no values are filled in, if one of the fields is filled in the error checking fails. Again, I'm extremely new to JS, i've only ever copy/pasted and this is the first time i've tried writing a piece.

View 2 Replies View Related

IE Runtime Error On Simple JS Code?

May 21, 2010

I'm getting a runtime error on the code in red. These functions are called by an onBlur by the way.

<script type="text/javascript">
//THIS GENERATES QUANTITY OF MATERIALS
function generate3()

[code]....

View 2 Replies View Related

Simple JSON Callback Error?

Mar 18, 2009

I'm trying to create a "Books I'm Reading" widget using the Readernaut API. I'm using JSON with a callback. This is a portion of what the JSON URL returns:

Code JavaScript:
parseResponse(
{
"version": "1.0", [code]...

View 1 Replies View Related

Remove Element Simple Script Error?

Dec 27, 2009

I am new to Javascript. I copied this script from the web, but I get an error at this line:parent.removeChild(child);The error says "Invalid argument".

<div id="parent" align=center>
<form name=mainfrm method=post>
<script language="JavaScript">

[code]....

View 1 Replies View Related

Simple DHTML Not Working - Syntax Error

Jan 19, 2011

I know I have a simple syntax error. Trying to call a function which changes the style of a div element on mouseover. Heres my code.
Javascript
function countermarker1(){
var box1 = document.getElementById('countermarker1box').style.display
box1 = "block" }
Variable is used cause I will have to use it more often later in the script.

HTML
<div id="countermarker1">
<img src="countermarker.jpg" width="20" height="14"
onmouseover = "countermarker1()"; /></div>
CSS (know its not really relevant just to avoid questions about whether its right)
#countermarker1box {
height: auto;
width: 80px;
display: none;
}
JS and css is externally srced.

View 6 Replies View Related

Function Call With Quotes Inside Another Function Call?

Feb 11, 2006

<button onClick="return popup('<span onClick='selectShape(1, 1, 1)'>test<span>');" tabindex=&#393;' onFocus="setFocusColor(0,3)">....</button>
This will work perfectly, but as soon as I need to pass Strings inside the selectShape function, I get stuck.

So the question is, how can I create the following and have it working

......selectShape(2, 'Tricky', &#3940;x5°').....

View 1 Replies View Related

Simple (simply Irritating) Page Refresh Error In NN

May 22, 2002

I have a VERY simple script to reload a page with fresh values when the value of a scroll menu changes. Trouble is, of course, NN 4.- freaks and closes the browser when this runs. No error warning, no error log?

The line..

<select name="Country" size="1" onChange="repopmenu(this,17)">

The script..
<script language="JavaScript">
<!--
function repopmenu(which,key)
{
n = which.value;
var url = ("eventedit.asp?country=" + n + "&key=" + key)
location.href = url;
}
//-->
</script>

View 2 Replies View Related

JQuery :: Results.push Is Undefined - Getting Error When Trying To Simple Traversing

Mar 29, 2010

I'm getting this error when trying to simple traversing.

results.push.apply( results, checkSet ); jquery-1.4.2.js (line 2743)

I read that it might have something to do with arrays?

View 2 Replies View Related

Simple Error Handling For Form - Avoid Alert Boxes?

Jul 21, 2011

I was trying to create JavaScript error handling for a form, and I was trying to get an error message to show up underneath the field where there was an error. (I am trying to avoid alert boxes.) I only have two fields, and my problem is that only one field is showing an error message. If I place an error in the input for the second field, the error shows up under the first field. How can I get the error messages to show up under the correct form field?

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL]">
<html xmlns="[URL]">
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<title>Carrots</title>
<style>
.qty {
width: 25px;
text-align: right;
}.blank {
display: none;
} .....

View 1 Replies View Related

JQuery :: () Call: Success In IE, Error In Firefox?

Jan 15, 2010

why the following code results in an error in Firefox and success in Internet Explorer?

jQuery.ajax({
type:"GET",
url:"http://nl.ae/iptocapi.php",

[code]....

No matter what I put in here, Firefox is going into the error; will not return success.What the server returns is just plain text, no html, thinking maybe it has something to do with This, but I can't figure it out because there are only So many options for

View 6 Replies View Related

JQuery :: IE8 And Apparently Error On .button() Call?

Nov 29, 2011

I'm Matteo and i have some problem with my website with jquery on IE8 browser. In the site I have a filter bar, partially crated with jquery. The code is that: <div id='filter_area_icons'>

<span><img src='/img/types_ico/small/1.png'id='ico_type_1'></img></span>
<span><img src='/img/types_ico/small/2.png'id='ico_type_2'></img></span>
<span><img src='/img/types_ico/small/3.png'id='ico_type_3'></img></span>
<span><img src='/img/types_ico/small/4.png'id='ico_type_4'></img></span>

[Code]...

View 2 Replies View Related

Second Call To Fuction Gives Object Required Error

Feb 21, 2002

I'm trying to build a cascading menu in javascript I got as far as this ; all I want to do is Re-draw the whole page when the link is clicked however I get an object required message the second time the link is clicked (I,m using IE 5) Code:

View 5 Replies View Related

JQuery :: Browser Stop Call's Ajax.Error

Sep 13, 2009

I've noticed that when I click the Stop button on the browser, or navigate to another page, jQuery.ajax calls the error event. You can see the problem live at: [URL]..

[Code]...

View 3 Replies View Related

JQuery :: Error In IE: Unexpected Call To Method Or Property

Sep 24, 2009

I'm using jquery-1.3.2.min.js and everything works perfectly in browsers other than Explorer... It's not liking this part:

this.appendChild(E)
function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})} ... }
I get this error:Unexpected call to method or property access. jquery-1.3.2.min.js, line 12 character 2305

View 1 Replies View Related

IE Error - Unexpected Call To Method Or Property Access

Aug 15, 2009

This error ONLY occurs in IE. "Unexpected call to method or property access."
I pinpointed it to this line:
o.appendChild(e);

The full function is:
function aO(d, t, src, p, id ){
alert('aO has begun.');
var o, e, i;
if (!ie){ o = cE('object');o.data = src; }
else { o = cE('embed');o.src = src; } .....

View 3 Replies View Related

Jquery :: Error When Calling Web Service From Ajax Call

Mar 30, 2010

I am calling web service through jquery ajax call for the first time and getting an error.

Below is the code:

Here is JScriptuserNTID.js file:

Here is WebService.asmx/HelloWorld:

View 1 Replies View Related

JQuery :: AJAX Cross Domain Call - 200 But Still Getting Firebug / Js Error

May 4, 2011

I trying to make a call to an external domain using $.ajax() and it WORKS, the server receives the call, but the response in firebug errors out in jquery.js line 7760. I've been beating my head at this all day and don't feel like I've made it much further.

I suspect it has something to do with the dataType or type of the request. But I've tried all kinds of things from POST to GET to JSONP in the type. For dataType, I've also tried "html", "text", "xml", "json", and even some combos of "text html" but no success.

[Code]...

View 13 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved