Why Don't You Have To Declare Variables In Javascript?
Jul 20, 2005
can anybody put forward a sensible argument javascript's behaviour of
creating a new global variable whenever I assign to a previously undeclared
variable. I can't beleive this is just for the sake of convenience (surely
we learned this much from basic).
here's my proposal: all "global" (document scope) variables must be declared
by 'var' outside a function block.
failing that, does anyone know any patterns or tricks I can use to make sure
I don't create a new global variable when I accidentally misspell a variable
name?
View 10 Replies
ADVERTISEMENT
Jul 23, 2005
I prefer to keep all my scripts in an external '.js' file. I am currently loading the external '.js' file from the header. Problem is I would like to declare a global variable in the external file, but I keep getting an error about the object does not exist.
Can someone tell me where or how to declare a global variable in an external file that is available after the page is loaded.
View 6 Replies
View Related
Jan 7, 2011
I have been working on a few budget scripts that I can access from the web in using HTML. My problem is that when variable values change I need to change these values in all of the HTML files on the server. I know that there is a way to declare global variables in a single file and use those values in another file but I have not been able to find any information that tells me exactly how to do this. I have tried to put it together on my own using what little informaiton I have been able to find but have not been able to get this to work. Is there a more detailed referance that I can find somewhere or does anyone know what steps I need to take to make this happen?
View 13 Replies
View Related
Nov 3, 2010
due to the version of dreamweaver i have (MX-2004) i have had to hand code a drop down menu myself however i have come across a problem.i'm not sure if the problem is in the Javascript, HTML, or CSS however here gowhen ever i hover over the menus dont drop down they cascade up and the other problem is that when ever i hover over one of the buttons a menu from another pops up and not the one that should. here is the codes so you can have a look
javascript:
<script type="text/javascript">
var timeout= 500;
[code]....
View 1 Replies
View Related
May 6, 2006
I have a program written in Javascript and fully functioning which takes a user-selected directory name and then displays all the photos in that directory in a certain format.
I am now wanting to expand the program to allow users to optionally enter their own strings and the program will use all the photos from www.flickr.com which use that string as a tag.
I have a PHP interface to flickr (called PHPflickr) which collects all the relevant photo urls. I now need to get these images back into my Javascript so I can process them using the existing functions (rather than rewrite all my functions in PHP code and have two sets of functions in the program). I found on another thread a means to do this for a date variable:
var jsArray = new Array(
<?php
$length = count($monthDataArray);
for ($i = 0; $i < $length; $i++)
{
echo '"' . addslashes($monthDataArray[$i]) . '"' . (($i < $length - 1) ? ',' : '') . "
";
}
?>
but being completely new to PHP I'm not sure what "addslashes" might be or what formatting will be necessary if I am starting with an array of urls. Code:
View 1 Replies
View Related
Jul 18, 2011
im trying to make a application, im trying to comunicate with the server with the function load, but it doesnt work, also i try with $.ajax, $.get, but nothing works, i have 3 files, html file, php file and javascript with jquery file,here are the php and javascript files:
javascript:
var x;
x=$(document);
[code]....
View 2 Replies
View Related
May 6, 2010
i am going to add thumbnail images on the right side of this page[URL]...like found on this page[URL]... also i am going to give the arrows the ability to navigate through the images i asked for advice in a different forum and was told that the image swaps i have in ggallen.html should not be inline as it clogs up the page...makes sense. i would like to know the best way to add the image swap function, or whatever is best for the job, to the thumbnails. also i would guess there is a more concise way of achieving the navigational behavior for the arrows than making separate divs which are shown/ hid on click.
View 1 Replies
View Related
Aug 27, 2009
$("input").blur(function(){
$.post("/designyourown/scripts/post.php", { id: $(this).attr('id'), value: $(this).attr('value') } );
$('img#preview').attr('src','preview.php' + '?' + Math.random());
});
the above code works how it is supposed to with elements hard coded into the page but if i add more elements with this code
[Code]...
View 2 Replies
View Related
Sep 8, 2010
I have cleated a bit of code that will dynamicly add a new line to a form so the use can add an infinat number of entires for this element.The code adds the form elemetns in IE and FF ok but when i click the submit button it does not submit the information from the dynamicly added elements in FF.Oddly enough IE works fine!Here is the code:
Code:
function addRow()
{
[code]....
View 1 Replies
View Related
Jan 19, 2010
I have written probably a rigged way of disabling and enabling fields and radio buttons. The only problem is that when i add the radio buttons to turn on and off the input fields wont work any more.
<script language="javascript">
function enableField()
{
[code]....
View 3 Replies
View Related
Feb 4, 2006
I have the following javascript function: Code:
function updateParent(dvalue, dfield) {
var field = dfield;
window.opener.document.form.field.value = dvalue;
alert("Value: " + dvalue + " Field: " + field);
self.close();}
I'm calling it as so:
<a onClick="javascript: updateParent(30,'image_id');">Update</a>
But I get the following error:
Error: window.opener.document.form.field has no properties
Why is it not picking up that I have defined the variable field as image_id?
View 2 Replies
View Related
Jul 23, 2005
I need to pass a javascript to JSP code but I cannot figure it out.
View 2 Replies
View Related
Jul 23, 2005
Does someone know how can we bring variables from a PHP script to a
Javascript one ?
I have to build a Javascript function that needs variables generated by a
PHP script but i do not know the way to retrieve them into Javascript.
View 5 Replies
View Related
Feb 23, 2006
I was just reviewing some javascript pop up window functions on my website and I descovered something... that I set the exact same variable name twice for both functions... which is bookWindow. I tested this for pages that use both functions and both types of pop windows work no problem. Is there a problem in that I use the same variable name twice? Is this considered bad form? Or maybe it makes not difference at all because the variable only gets used when it is
called upon and then it leave memory.....
View 2 Replies
View Related
Oct 30, 2006
I have some image data in a Javascript variable, and I want to display
it. I have a technique which works in Firefox but not in Internet
Explorer :
<script>
var testImage = <image data as a string>
</script>
<img src="javascript:testImage"></img>
I understand that this should work in Javascript 1.2 and above, which
supports null characters in strings. Does anyone know why this doesn't
work in Internet Explorer?
View 3 Replies
View Related
Jul 20, 2005
Here's the situation. I have a static html page which we want to update
to include some dynamic content. I want a counter that keeps track of
the number of times anyone presses the "add" button, and display that
number. So, that page would look something like:
Number of calls today: 5
Add | Reset
The "5" would increment with every click of the "Add" link. The "Reset"
link would reset the counter to 0.
I have a Perl script that does all of the accounting stuff (opens a file
that contains the number, increments it, resets it, etc). What I don't
know how to do is to get the data from the CGI script to the web page.
I'm imagining that you can use Javascript, but I can't figure it out.
My CGI script can accept three options (add, view, reset). So it you
call it like so [myscript.cgi?action=add], it increments the counter by one.
So, in a nutshell, this is what I want:
1) the web page to display the # of calls upon load.
2) When a user presses the "Add" link, it invokes the CGI script to
handle the accounting stuff, then refresh the page with the new number
of calls.
3) When a user presses the "Reset" link, it resets the counter to 0.
View 6 Replies
View Related
Jan 18, 2007
I was handed a project that, when launched, had some ajax problems--specifically, "Error: uncaught exception: Permission denied to call method XMLHttpRequest.open." That's easy enough to fix--found the call in the .js file that was referencing the development server instead of the live server, and I am aware of Javascript's same-origin policy, which makes good clean sense. Change that call, problem solved.
Unfortunately, it's not solved. I can change the reference from
var url='http://www.devserver.com/function.php?id='+id;
to
var url='http://www.liveserver.org/function.php?id='+id;
but that doesn't solve the issue of if someone comes to the page without the 'www' or to the other domain, whose TLD is a .com instead of .org.
In PHP, I'd simply write the function to dynamically generate the url string, using $_SERVER variables rather than hardcoding the url. But I'm no javascript guy. Any help would be appreciated.
I'd rather not have to put a php redirect in every page to make sure the url is what I want it to be. I'd much rather learn something new about Javascript.
View 3 Replies
View Related
Jul 16, 2006
A while back I was working on learning C++. However after finding out that making API's was too difficult I switched over to HTML and Javascript for a while to get it to do what I want without having to fry my brain on weird code statements.
Well now I've reached the barrier of being able to save data. For a while I've just had it to the point where the code I need is saved in a textarea and I copy and paste it in notepad. Then upon reentering I pull it out of Notepad and paste into the testarea.
Well enough with the bla bla bla. Is there a way I can use the <form method="post"> stuff to pass a variable to a C++ compiled program?
All I need to know is: 1) can I use <form method="post" action="SomeProg.exe"> and 2) what would the name of the posted variable be to use in my C++ code? As you can tell I running client-side so PHP and other server-side languages that WinXP don't support without special installation wont work.
View 2 Replies
View Related
Jul 25, 2001
I am pretty new to Javascript and have only created a few pretty basic scripts, mainly dealing with site navigation and mouseovers. I would like now to redo my private home page using a rather complex configuration of frames. It is my intention to use JavaScript (variables) to control the rather intricate page navigation.
My question is this. I know how to define a variable, increment or otherwise alter it's value and how to change a process path based on the value of a variable. I have done all of this within the SAME page. What I would like to know more about is the referencing and modification of variables in "pages" in other windows within a frameset.
View 2 Replies
View Related
Jan 29, 2007
I have something that runs on a server with no PHP or any of those widgets.
A user submits a form with 6 fields. Clicks "Go". A page appears that displays what he just entered, with a form of his data in hidden fields, and a link with document.form.submit() that takes you to a CGI program. It must be 2 different page loads.
Is displaying what he entered in the form in the next page possible with JavaScript? If so, what are the JS variables that would let me access that data?
View 3 Replies
View Related
Aug 30, 2011
I seem to have come across a weird issue in internet explorer.I've been working on doing regular expressions for a register form, and I've checked it in Firefox, and Chrome and it seems to work for both of them but yet it doesn't work for Internext Explorer 6 - 8.The issue is that the drop down boxes (select fields) dont seem to be recognised for RegEx in I.E. this is causing an issue for me as I want it to work in ALL common web browers as well as keeping the whole form standard.
I've pasted a snippet of code below to show you what I've done.This one below is the original one which just checks if the field entry is blank
function check(theForm)
{
var checker;[code]...
If you have any Ideas about what I can do to make it work in I.E. I would be most greatful. Also if anyone knows how to do and RegEx on a checkbox that would help me quite a bit too.
View 9 Replies
View Related
Jul 23, 2005
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:
href="javascript:
newWin('/vcrc/exitvcrc.jhtml&newURL=http://www.something.net/default.asp?sponID=ETC','NowLeaving',駼',
餠', 'no', 'auto','no');"
So, pretty much, the page I'm sending the variable to think there's two
variables (newURL and sponID), but sponID is part of the URL.
View 2 Replies
View Related
Mar 20, 2007
i have the following snippet of javascript:
liChilds[x].onclick = function(){
toggleSubMenu(sub_menu_id, false);
return false;
}
That code happens within a loop, and sub_menu_id has a different value through each iteration of the loop. For example, if it loops 4 times, then there will be 4 onclick functions and sub_menu_id would change for each one. This should happen in theory, but instead, whichever item you click on, sub_menu_id takes the value of its last value in the loop. (4 in this example)
My question is, how do I make the function toggleSubMenu take the value of sub_menu_id at the time the on click function is created (i.e while looping) rather than taking the value of sub_menu_id when it is actually clicked.
View 2 Replies
View Related
Feb 4, 2005
I'm having a problem getting javascript and vbscript to place nicely together. Here is what I want to do:
I'm getting values from my database for different exam types. Here are some sample values:
Exam Type1
Exam Type2
Exam Type3
Here is how I get the values in vbscript: Code:
View 5 Replies
View Related
Aug 10, 2006
Is there any simple way of passing HTML variables from one HTML page to another HTML page without using PHP or messy URL extensions?
View 5 Replies
View Related
Jul 20, 2005
There will be a number of list boxes and other controls, with pop-up windows
to edit certain properties. It's the kind of thing I would normally have
done in VB but I want it to be browser-based. I've only used javascript for
trivial things before so this would be my first serious javascript
development. I would like it to run on all reasonably recent browsers.
The form starts with all the initial values being received from the server
(presumably just by pre-initialised data structures). The user tinkers with
it and when he is happy he presses 'submit' and the whole lot is submitted
to the server (presumably as a form post). This would be a few kb of data,
possibly 100 individual values but obviously in various data structures. I
guess there would be a few hundred lines of javascript code to manipulate
it.
My question is, is there likely to be a problem with manipulating and
sending this amount of data in Javascript. Sorry if this is a dumb question,
but like I said, I only used javascript for tiny programs before, so I'm a
bit unsure about its capabilities.
View 2 Replies
View Related