I'm new here, and new to js. Here is my problem: I have written out a code to make an image switch from state 0 to 1 and back to 0 again (an eye blink). The code works fine, but I would like to write the functions with arguments so it could be applied to more images. I have tried for a few hours (and searched forums) and am getting no where. Here's my code.
Code:
function home_blinkDown()
{
//alert('blink down');
var t = setTimeout("home_blinkSwap('home_js', 'images/main/home_blink.png')", 2000);
I'm trying to trap a user entry that cannot be found in the database. When a code is entered, the page should give a "Code Not Found" message if it is an undefined value.
However, it didn't; and it always shows the "undefined" value to the page instead.
for some time I always found a workaround for this kind of problem. But somwhow, it feels wrong. So I'd like to know, if there's a common way to solve something like this[code]...
I'm defining the function and if the value of 'obj' hasn't until the function really gets called, this can work. But it just feels so wrong do have always global variables just to access them inside of a callback.[code]...
I'm having a problem passing a variable through a URL because the variable is supposed to hold a URL that has a variable of its own. Here is an idea of what I'm trying to do:
I'm trying to pass data to my mySQL database, but I'm doing that 2 jQuery scripts:User comes on my page where there is a list with some values, e.g 530, 532, 534 etc etc ..User clicks on one of them, this link is using the jQuery to get another php file which get's the data from my DB and list it below the first list, here's the code for this:
So the second list is another step that can't be avoided to get the final result. In other words, i'ts another list where the user has to chose one of the items from the list to see the final result, I've added this code inf the 'e.php' file:
The problem is that my 'f.php' only gets 1 variable value, but I'll need 2 or more (maybe in the futur), how to pass multiple variables to a php file using jQuery?
First off I didn't know whether to post this here or in the PHP section since it deals with both, but mostly JS. I have a PHP scraper that scrapes the job title, company name and location from a website and stores them in separate arrays. These values are then extracted out one at a time from the array and stored into a string, that is then passed to a Google Maps API.
I can make this successfully happen once, the thing is I need to do it multiple times. I have an idea on what I should do but don't really know how to implement it (correctly). The idea I had was to create a function in the JavaScript section that accepts three values from PHP. This function would be called in my PHP for loop that extracts the values from the array into a string. The thing that confuses me is that the Map function is called via <body onLoad="initialize()">. Here's the link to my code (http://pastebin.com/rTfzJM16)
I am currently working on a function that will allow the user to search for an event by date and category. I've been using the w3schools exercise as an example but i wish to pass 2 pieces of data instead of one and am not sure how to do so. I'm sure similar posts have been raised before and i apologise if this type of question has already been answered but i could't find it in the forum index.
<FORM name="myForm"> <INPUT type="text" readonly name="MyDate2" value="Click for Calender" onClick="toggleCalendar('MyDate2')"size="15"> Select a Classification: <select name="Classification2">
[Code]...
Even just point me in the direction of a good article or tutorial, i've been banging my head against it for 2 days so i'm very willing to take a few hours to go through a tutorial
I've noticed that if you declare a variable in one function, then call another function, the variables cannot be accessed in that function. Is there any way to get the value of a variable declared in a different function?
I cannot findout how I can write to global variables in a a JQUERY function. <script type="text/javascript"> function checkusername (username ) { $.post("[URL]", { action: 5, username: username }, function(xml) { result = $("apot", xml).text(); //<-- this variable is not global... why ?? message = $("message", xml).text(); //<-- this variable is not global... why ?? alert(message); //<--here variables are shown ok alert(result); }); alert(message); //<--here variable is NULL !! alert(result); //<--here variable is NULL !! } </sctipt>
I am working on a simple Expanding Family Tree. There are two principal Objects: Person and Family, and two subsidiary ones: Sibling-sets and multi-Marriage-sets.
When I click on a Family Button, I want to display all the Persons of a Sibling-set. Married Siblings will have a Button. Pressing this should display one or more Marriage-Partners. If these Marriages (Families) have children, they will have a Family-Button.
You will notice the code for the four objects is fairly repetitious, but that for the variable-length Sibling and Marriage Arrays, is what has kept me struggling for days. Lines S04-S10 and M04-M10 appear to be the problems.
Even though I think addSibling() is constructing Sibling objects, S06 reads the Argument vector as a single item S07 tells me the argument-count is 1. so S09 processes only once, and then.. it interprets argv[s] as a single item, but assigns the whole array to this.sibA.
Recently I decided to branch out and learn some Javascript on my own. I'm getting the following error: Uncaught ReferenceError: array is not defined
I don't quite understand why I'm getting this error, as I've created the array in the function showPrompt and it seems as though it's being passed around correctly. However, I believe the problem is with generateBoxes, specifically this part here:
onclick=\"getValue(array, i)\" (line 39)
Removing array from the function parameter seems to make it execute, but beyond that, i'm lost to what is wrong.
Here's the code:
function showPrompt () { Obtains user input var array = new Array(); var box = prompt("Please enter number of boxes","1");
For some reason, I am using document.referrer in a PHP script that is called as a JavaScript script. The problem is that I need to pass the value of document.referrer to a PHP variable (in the same file) in order to add it to the database. How can I do that?
I am familiar with the user built addEvent function used to load multiple functions in the window.onload property. However, I am curious as to the best way to do this across multiple JavaScript files. I thought I had seen somewhere code similar to the addEvent function was native to JavaScript now but I can't seem to find that anywhere.
Just to clarify, suppose I have 3 JavaScript files:
Code: function foo() { // do something here } fileB
[Code]....
note that it is not feasible to combine those functions into one file as they aren't always loaded together. What's the best way to load them all as a window.load?
I would like to display the number 1 at first and then 2. but this code produces number 2 for both alerts. I was able to achieve what i wanted with "new" constructor when creating functions but this is not a good practice and after all i am passing these functions as an event handlers and it can't be done with "new" keyword because it is throwing error. I think there are some solutions with arrays e.g the x would be an array of numbers, but i don't like it. Am i missing something important?
This probably seems pretty trivial to you experts but I just don't know why it doesn't work and would like a nudge in the right direction please.I have a sllide and fade that works great - no problems. I am firing it with a function call from the HTML like so;<a href='#' onClick='sfade('#s1'); return false;>as you see I am passing the div to be faded(and slid) as a variable. Works great. The receiving function is:
var str=''; function sfade(str){ $(str).slideFadeToggle(1000);
I'm creating dynamic buttons and forms for a website and would like the form hidden when it's corresponding button is clicked. However, when I pass button and form name variables to my JavaScript that hides the form, the variables are not being recognised unless I explicitly set them. (e.g 1 and 2 as seen below).
In a nutshell the onlick event doesn't seem to like PHP variables !