I know the answer must be yes, but I am really having a hard time figuring this out. I have a simple script below, that calculates age (I know I need to do some more work). I want to redisplay the value returned from the function. It works OK, because the result displays correctly in the alert. Code:
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?
i've got a function which makes a call to the database( via jquery $.post) to check if a username already exists. All the data I get back is fine and both the conditional statment works as intentded. I just can't get the function to return a value to the other function that calls it. Could this be something to do with the scope.
Afternoon all, Have a pretty simple function, that requests a number to be entered. I want to return that number, but i seem to be typing something wrong in the return value.
function newFunction(a, b) { var newArray = new Array(a); for (var i = 0; i < 5; i = i + 1)
I am populating a field on my page using a php include. I am asking javascript to update another element with that field's value. The value written to the select input box is Ƈ:Any Provider'. The process works fine in Firefox. In IE6 it does not write. the value nor does it throw an error. What am I doing wrong?
function postthis(){ var provider = document.inputForm['provider'].value; var report = document.getElementById("status"); var message="The Value of Provider Block is: " + provider; report.innerHTML = message; }
In firefox, "The Value of Provider Block is: 1:Any Provider" is written in the report element. In IE6, "The Value of Provider Block is : " is written in the report element.
I have a form and a submit button .on clicking submit button function validate call.this function call another function (say func) .this func function vallidates some input and return true or false value to the validate function this then return true or false value to the submit button .I want that func directly return true or false to the submit button.
I have a multiple choice quiz that works fairly well. However, instead of it presenting "End of Quiz" message when last question is completed I need it to take the user back to the beginning (question 1) but with no indication to the user that this has been done. How can I adjust the code to have it do this?
<script language="JavaScript1.1"> var whichone=1 var tempmn=document.quiz.thequestion function generatequestions(){ document.quiz.theresponse.selectedIndex=0
I want to pass a javascript function's return value, to an anchor tag's href parameter i.e. <a href>
Suppose I have a function called getTrackingCode( ) that contains a value "testSite" <script language = "JavaScript"> function getTrackingCode( ) { return "testSite"; } </script>
Now I want to pass this function's value to anchor's href, I have attempted these:
I have a desire to include more than one return statement in a function I have written so that when it has found the solution to a hit-testing series of conditionals, it returns the solution. The desire is to avoid further hit-tests when solution has been found. I've always felt that more than one return statement in a function is poor style, since it may lead to false execution of a function - by way of a later code edits - making a mistake by forgetting the multiple returns. My function is short and maybe the optimisation exists only in my head but are there serious reasons why one should not have more than return statement? This JS code executes in the Quartz Composer framework and has nothing to do with we programming (context (-:)
Here it is with three returns, it 'works' and I could replace all the break statements with return statements to finish optimizing: //Test for y inside range for all quads ( Quad is defined by 4 points in a row in the list is a quad ie. list[0-3], list[4-8], //Test along the unit numerals (_N) and also the 'Revert Patch' button if (y >a[0]["Y"] && y <a[2]["Y"]) { for (i=0; i <37; i+=4) { //Log("DDDDDDD "+i+" X:"+x+" Y:"+y); .....
I've been reading up on Javascript. I read that you can use:
document.write("<h1>My Test</h1>"); So I wrote a little script: <script type="text/javascript"> var choices = new Array(); choices[0] = "<img src=\"crush.png\" />"; choices[1] = "<img src=\"curse.png\" />"; choices[2] = "<img src=\"endless.png\" />"; choices[3] = "<img src=\"eyes.png\" />";
My function the_magnitude() takes in values from 4 different asp:textboxes. The textboxes "easting" and "northing" contain numbers that don't change, but the textboxes "east" and "north" contain numbers inputed by the user, and the function returns "error" as a value to be put into another textbox that we'll call "error box". So what it's suppose to do is when I update the information in either "east" or"north" it will update, on change, the number in the "error box". It kinda works.My problem is that if the number is a value that changes the style to red, #ff0000,in the function it wont update the "error box" and it just leaves a red zero that is a default number in the box. The only way I can get the number to change is if I end up with a number less than 200, which would make the text green.I'm pretty sure it's a problem with my javascript.here is my function
<script type="text/javascript"> function the_magnitude(easting, east, northing, north, error) { var a = easting.value;
I am relatively new to js, but I did think I was starting to get the hang of it. Then this happened...
I have a form with an onsubmit event handler: <form id="uploadForm" method="post" action="..." onSubmit="checkDates()">
The event handler does some minor validation, then returns true or false:
function checkDates(y, m, d) {
if (endDate.getTime() >= startDate.getTime()) return true;
alert("Start date must precede end date"); return false; }
(The arguments to the function are used when it is called elsewhere, not as onsubmit.)
I also have a library class which needs to process the form submit, so it hooks onsubmit like this: MyClass.setOnSubmit = function(listId) { var list = document.getElementById(listId); var form = list.form;
var f = form.onsubmit; if (typeof f == "function") { form.oldOnSubmit = f; form.onsubmit = function(){ var ok = this.oldOnSubmit(); if (ok) return MyClass.onsubmit(listId); else return false; }; } else form.onsubmit = function(){MyClass.onsubmit(listId);}; }
My problem is that the value returned from oldOnSubmit and stored in ok appears as 'void'. This happens in IE 6 and in FireFox 1.07. Can anyone explain what's happening?
function getParentElementByTagName(child, TagName){ var cn; if (child.parentElement){ cn = child.parentElement; if (child.parentElement.tagName == TagName){ return cn; }else{ getParentElementByTagName(child.parentElement, TagName); }}}
although it finds the element, the function returns null ( on the line 'return cn', cn is not null though). Is my algorithm wrong ?
I thought that the value of startDate would end up as the defaultDate param for datepicker. No luck. Only an obscure little message in firebug console: "missing: before statement"
I wonder how I can get a return value from a JavaScript function to a jQuery function. I have dynamic divs that creates each time I push a button and I want to retrieve the new div ID in my jQuery function sow I can get my date pick to drop down.
javascript function to retrieve the new div ID function currentCustomerDivName() {
I have some problem using the $.post function. I wrote a function that test if a username is already used in my database. That function must return true if the username is free and false in the other case. My problem is that I use the $.post function and I put the return true; and return false; in the callback function. So it's the callback function that returns true/false instead of my function !
Here is my code : function validateName(){ $.post("ajax_is_name_used.php", {name: $form_name.val()}, function(data) { if (data.success == 1) { $form_name.addClass("error"); return false; // Problem, we are in the callback function ! } else { return true; // Problem, we are in the callback function ! }}, "json");}
I'm not too good with programming, but I'm trying to get my feet wet with some nice little AJAX tools. I have some things currently working, but I'm trying to re-write the code so I can reuse these modules for a number of functions....As of now, I have a function that returns XHR requests [ ajaxRequest(){} ]. I am calling this function inside an XML Parser called [ ajaxParser(){} ]. Once that's created, I have the following code:
Code:
xmlDoc = new ajaxRequest() xmlDoc.onreadystatechange = function(){ if (xmlDoc.readyState == 4){ if (xmlDoc.status == 200){[code]....
At this point, I want the function to return an object that holds all the XML Node names, lengths, textContent, etc. I would like to be able to call this in any other function I write and begin traversing the nodes there. Something like root = new ajaxParser(file.xml);I tried "return parentMenuList;" except the length return is undefined. What I see in the DOM inspector is an object called root (with no other properties to it).
i cant find a way to return a value to a function inside a class...seem that when try to output it(the code with red markup)..its output is undefined..
function AjaxProcess(ElementId,amethod,url,element,callback_function,acontrol,ProcessImage){ this.ElementId=ElementId; this.amethod = amethod;[code].....
I have this code <TR id="tr1" onClick="var ret_val = clickedfun(this.id)" /> and this javacript code <script language="javascript">function clickedfun(tid) {var elemento = document.getElementById(tid);if(confirm("Tem a certeza que quer remover esta fila?")){elemento.style.visibility='hidden';var numero=tid.substring(2,tid.length);return numero;}}</script>; I want to get the return value of the javascript function to use in database for deletion of that value. I am using jsp and java classes.
I am working on a function where I need to return the active elements ID. The element will have: class="main" id="1" onmouseover="showSub()"> Would someone be able to write me a simple function which simply puts the elements ID number in an alert box?
Here PointsOfInterest[i].lat = 56.45556, PointsOfInterest[i].lng = -2.5413 and i = 2;
I want to be able to store these three values into three global variables in Javascript in order to use these variables somewhere else on the same page as their source.