Function To Return Active Elements ID
Jul 24, 2011
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?
View 6 Replies
ADVERTISEMENT
Sep 27, 2009
So my code is supposed to retrieve three values from a flash element. Now it works fine, but when it retrieves a 0 from any of the three valuse, it goes all haywire. How could I put in a statement or command that if it returns 0, that all it will display is a 0 instead of returning "NaN"? But since all three valuse added together are supposed to equal 100% i have to run the numbers through a little bit of division and rounding after it gets the value of each one.
var techfaction = document.getElementById('tfaction');
var natfaction = document.getElementById('nfaction');
var magfaction = document.getElementById('mfaction');
retrFaction();
roundNumber();
function retrFaction()
{
var values = document.documentElement.innerHTML.match(/factiontrianglesmall.swf??.*\x26link/i)[0].match(/[0-9.]{4,9}/ig);
techfaction.innerHTML = roundNumber(values[0] / 30, 1) + '%';
natfaction.innerHTML = roundNumber(values[1] / 30, 1) + '%';
magfaction.innerHTML = roundNumber(values[2] / 30, 1) + '%';
}
function roundNumber(num, dec)
{
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}
View 2 Replies
View Related
Jun 8, 2011
getting all the header text:jQuery("#accordion h3").text();how do you get the active index? and how do you use that index to get the active header?how do you get the header text for the active header?
View 1 Replies
View Related
Oct 23, 2009
I have nested markup like this
Code HTML4Strict:
<li><span></span></li>
I have different click functions, one attached to the li and the other to the span.
When I click on the span they both run. Ending the span's event handler with return false; prevented that from happening, which is what I want. But I'm not sure I understand why it worked.. I know, for example, if I was clicking on an anchor, return false would stop the browsers default action of following the href value. Same for submitting a form, return false will stop this. I don't think I understand why this would stop a completely different function from being triggered..
View 7 Replies
View Related
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
Aug 7, 2009
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.
Code:
function checkIfUsername(o)
{
$.post(""+CI_ROOT+"index.php/admin/check_if_username",{
username: username.val()
}, function(data){
if(data.bool == true){
[Code]....
View 4 Replies
View Related
May 17, 2009
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)
[Code]....
View 12 Replies
View Related
Aug 21, 2007
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?
input form:
[PHP]<form method="post" action="" name="inputForm">
<label for="provider">Name of Provider</label><select class="input" name="provider" size="1" style="width: 20em"><?php nameprov();?></select>
<input type="button" name="button" value="Upload" onclick="postthis()">
<div id="status"></div>
</form>
The script in the head element:
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.
View 7 Replies
View Related
Nov 23, 2005
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:
View 23 Replies
View Related
Mar 6, 2006
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.
View 2 Replies
View Related
Jun 13, 2011
How can I use the return value from prev_picked() in my ajax call?
Code JavaScript:
function autosuggest_results (info)
{
if (info.length > 1)
[Code].....
View 1 Replies
View Related
Jul 11, 2006
Can javascript using pointer or pass variable by reference?
Or I need to using object or Array to return the two values?
View 2 Replies
View Related
May 4, 2009
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
[Code]...
View 7 Replies
View Related
Sep 7, 2009
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:
[Code]...
View 5 Replies
View Related
Jun 29, 2011
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); .....
View 3 Replies
View Related
May 11, 2009
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\" />";
[Code]...
View 4 Replies
View Related
Aug 9, 2010
How do I pass results back to textService so that I can make a call such as textResult = textService(text to pass in);
I don't want to use a global variable if I can avoid it. This is the code
Code:
function textService(text){
req.open("GET", "http://....?text="+text, true);
req.onload = showResults; req.send(null);
}
[Code].....
Basically I would just like these two functions to become one function with a return value.
View 1 Replies
View Related
Feb 7, 2011
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;
[code]....
View 2 Replies
View Related
Jan 9, 2006
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?
View 8 Replies
View Related
Aug 15, 2006
Here's the function:
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 ?
View 4 Replies
View Related
Nov 14, 2011
I'm trying to make a call to .ajax and as a result set a value in a hash (for another call to jquery-ui)
I get the data coming back fine, could put in in a text field in html but not the hash where I want it.
Here below are the parts of my code that I'm using
//setting up datepicker
$(courseStartDateHtmlId).datepicker({
.....
defaultDate : ($(courseStartDateHtmlId).val() != "") ?
[Code].....
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"
View 3 Replies
View Related
Jun 3, 2010
as I can return a second value of the autocomplete function?
the script
<script type="text/javascript">
$("#nombre").autocomplete("<?php echo base_url()?>transportistas_controller/autocomplete_partidos");
$("#nombre").blur(function(){
[Code]....
View 1 Replies
View Related
Apr 1, 2011
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()
{
[code]....
View 2 Replies
View Related
May 6, 2009
If I have this:
$.post('/admin/duration', $str, function(data){
var jsonData = eval('(' + data + ')');
return jsonData.TIME;
});
How do I get the return value from the function to use afterwards? I know this must be simple. I'm just not seeing it.
View 1 Replies
View Related
Sep 30, 2010
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");}
View 4 Replies
View Related
Jun 23, 2009
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).
View 1 Replies
View Related