Calling A Variable Inside A Command?
Mar 31, 2010
im not sure now to word it, or how to do it, im a php coder not a javascript -.-but here it is, basicly i have one ajax file and wish to use it for everypage,i tryed to do it so i can just call one function for all ajax uses, but forms seem to be thowing me off when i call it, i stat if its a form or a element,
function ajax(str, b, c) {
a = b;
type = c;
if (type === 'form') {
[code].....
in this, the variable a is set as the id of the elemnt/form, it works fine for elemnts, but not for forms,i think this is because its thinking a is the id, not the variable,
View 2 Replies
ADVERTISEMENT
Nov 26, 2010
I have an embarrassingly similar problem to the last time I was here. I have a google map that generates links and checkboxes from an xml file and puts them in a sidebar. The links open infowindows and the checkboxes show or hide lines on the map.
Which all works ok. But (like last time) I have another function that puts arrowheads along those lines to indicate directionality.
The code which turns the lines off and on looks like this:
function togglePoly(poly_num) {
if (document.getElementById('poly'+poly_num)) {
if (document.getElementById('poly'+poly_num).checked) {
gpolys[poly_num].show();
[Code]...
View 5 Replies
View Related
Apr 11, 2007
consider the next code:
var obj = {};
with(obj) {
var x = 10;
}
print(x);
print(obj.x);
It prints 10 and undefined. Here, one could expect that obj.x get the
value 10. But it's not the case, because variable declarations are
placed at the start of function code (or global code), so the
previous code is equivalent with:
var obj;
var x;
obj = {};
with(obj) {
x = 10;
}
print(x);
print(obj.x);
You can clearly see now that x is placed in the outer context. But
consider the next:
var obj = {};
with(obj) {
eval("var x = 10;");
}
print(x);
print(obj.x);
I was expecting that obj.x would get the value 10 here. But no, it
gives the same output as the previous code. I tested it with
spidermonkey, kjs and ie jscript. Looking at the ECMA spec, I could
not find anything that describes that behaviour. Code:
View 3 Replies
View Related
Aug 17, 2010
I am trying to declare a variable inside a function and use it later on in my code... but it just already returns white space... i.e. not variable value. I am setting it within this function:
function show_video1(){
document.getElementById('video1').style.display="block";
var video1Name = "Education World News (Part 1)";
document.getElementById('video2').style.display="none";
document.getElementById('video3').style.display="none";
document.getElementById('video4').style.display="none";
[Code]...
and trying to call it later on with this: <script type="text/javascript">document.write(video1Name)</script> It might be worth noting that each one of my 11 videos will hace a different name.
View 13 Replies
View Related
Sep 9, 2009
i guess this isn't really jQuery specific rather than it is a global JS-thing, but I tried general solutions for this and they all did not work so I figured this might be because I'm trying to do this with the $ function.
What I wanna do is this: I have a document with an iFrame. From inside that iFrame I wanna call the $-function of the original (parent) document. I tried so many things like
parent.$
top.$
window.parent / top.$
the stuff above with .document.$
and other stuff but none of that works. So, how do you call $ of the real document from inside an iFrame?
View 1 Replies
View Related
Jun 10, 2011
proper way to execute helloThere() from the parent function getHelloThere()? This code is not working for me...
index.html
--------------
<script>
function getHelloThere()[code].....
View 1 Replies
View Related
May 1, 2009
I have a huge form with a lot of data.
There is a table that data in it I need to display on a print screen (of course this data isn't being displayed in the regular table).
So, I put the display text in a span tag.
So, this is how each item will look:
I need a way to grab all spans on the page that have the attributte of "printData" and grab that text inside that attribute and print it out.
View 3 Replies
View Related
Jul 21, 2009
This is probably more of a basic javascript question than a specificjquery function.I have this jQuery function named validateSubmit()which calls two other regular javascript functions. When using IE,both createCharts() and getDirectorIDs get called but when usingFireFox, only createCharts() gets called and never makes it togetDirectorIDs() and I'm not sure why this occurs.
<script type="text/javascript">
// make sure at least one checkbox is checked
function validateSubmit() {
[code]....
View 12 Replies
View Related
Dec 28, 2010
I am calling a program using $.getJSON() inside of a for loop. The problem is that the second callback doesn't wait for the first program to finish before it executes. Is it possible to ensure that the second iteration of the loop doesn't happen until the first one is finished?
$('#dialog-form').dialog({
buttons: {
"Import": function() {
var ids = $("#itemsGrid").jqGrid('getGridParam','selarrrow');
[Code].....
View 1 Replies
View Related
Jul 12, 2010
I am trying to call a function from a link or button like the example below, however I would like to call the function whilst passing a variable along (not a string).
This isn't my code, it is a simple way of explaining what I am trying to do.
<html>
<head>
<script type="text/javascript">
function myfunction(txt){
[Code]....
So instead of 'java too!' I would have a variable named "category" which could contain different data each time the button is pressed.
View 2 Replies
View Related
Jul 23, 2005
I am using a javafunction (onclick in select) in which i am calling a
function in php (thats why i send this to both php and javascript
newsgroups).
in the onclick i call the function "Place_Selected" with the value from the
select (naam_keuze.value)
in the function the value becomes the $zoek_id and searches in the database
for the record with the id of $zoek_id
the naam_keuze.value does not give the value to $zoek_id When i replace naam_keuze.value for a number (15) i works great.
WHAT AM I DOING WRONG? Code:
View 5 Replies
View Related
Aug 13, 2009
The code below is the relevant part to an autosuggest feature. The variable that isn't being passed is "firstValidIndex". It is being set appropriately, but when it is used in "sortArray()", its value is 0.
// here we must check to see if where the string matched was at the beginning of a string inside this.aNames
// firstValidIndex is the first index where the char is at the beginning of a string
[Code].....
View 5 Replies
View Related
Mar 15, 2010
I am writing one function for product of two number. I am sending two textbox name with appending its rowid as variable to the function.will it possible to pass this dynamic variable to any function ? In below code, On event Onkeydown, I am calling funcion product with three iput dynamic variable. when i run this code,html page does not show any rows in grid.
[Code]....
View 1 Replies
View Related
Oct 11, 2010
I've looked extensively for the answer to this but suspect my inexperience means I'm using the wrong "keywords" in searches, or the answer involves jquery beyond my comprehension.
I have script experience and have plug-in galleryView working but have no jQuery experience which is the problem.
The script:
<script type="text/javascript">
name
= getValue("name");
$(document).ready(function(){
[Code]....
Variable name contains data stripped from the page URL (www.url.com?name=3). I want to use this variable in the jquery array/list passed into the galleryView instead of the number 3. How can this be achieved? I suspect this could be done entirely in jquery (if I had the experience) or via the getdata script used above?
View 6 Replies
View Related
Feb 15, 2011
In my code a JavaScript function received value from html hyperlink. Value passing successfully, inside product function document.write(a) printing value 5. But how can i print value of "a" inside product function by php. My code is here....
<html>
<body>
<a href='javascript: product(5);'>click</a>
<script type='text/javascript'>
[code].....
View 7 Replies
View Related
Oct 30, 2006
I think I've had JavaScript variable scope figured out, can you please
see if I've got it correctly?
* Variables can be local or global
* When a variable is declared outside any function, it is global
regardless of whether it's declared with or without "var"
* When it is declared inside a function, if declared with "var", it's
local, if not, it's global
* A local variable that is declared inside a function is local to the
whole function, regardless of where it is declared, e.g.:
function blah() {
for(var i ... ) {
var j ...
}}
i and j will both be visible within blah() after their declaration.
* the notion of "function" in this context also applies for this kind
of construct:
var myHandler =
{
onClickDo: function()
{
in the sense that whatever one declares inside onClickDo with "var"
will only be visible inside onClickDo. What else, am I missing anything?
View 4 Replies
View Related
Jan 18, 2010
I'm using the following to sequentially change the background color of some list items. It works, but is there a direct way of putting a variable inside the n-th child parentheses, instead of concatenating? Second question, more CSSey, though. The highlight goes all the way across the page since the CSS bounding box is 100% for the li items. The lines are various lengths so I can't just set the bounding box to, say, fifty percent. Is there a way to use jQuery to make the bounding box, or background color only go to the end of the text?
View 1 Replies
View Related
Jun 6, 2009
I have a problem that 'test' is not passed. The following function alert undefined, but it should alert test. Why that?
PHP Code:
View 1 Replies
View Related
Jan 9, 2008
I'm making a project which creates tabs with a class. I don't really know how to explain it better but this is how it works:
<a href="#" id="tbs_tabs">Create</a>
<script type="text/javascript">
var tbs = new Tabs('tbs_tabs');
tbs.theme = 'classic'
tbs.create_option('abc','#');
tbs.create_option('abz','#');
tbs.create_option('abf','#');
tbs.create();
</script>
It first creates the new class and tells it the id, then it creates as many options as you want and creates it.
My problem is with this line:
for(i=0;i<this.option_values.length;i++)
{
li = document.createElement("LI");
li.appendChild(document.createTextNode(this.option_values[i]));
addEvent(li,"click",function(){oThis.select_option(i); return false;};
ul.appendChild(li);
}
What I was trying to do here is add an event to the LI element that refers to the current tab class but doesn't use the CURRENT i value but the value that was when the event was first created.
For example.. If my i value is currently 2 and I add the function, then I want that when I call the function, the value will still be 2 and not the current i value. What happens now is when I call the function the value is something like 5 or 6.
View 2 Replies
View Related
Aug 12, 2009
In my application i am using Ajax post like:
The Form id as returned from the Controller side is saved in the variable getformid correctly, But it is not reflected in the savefield ajax post..And it is saving as 0 only even it alerts as the returned Form id..
In addition i am giving here the Code inmy Controller for saveForm:
And my Model saveForms is like:
And my save_form.ctp in my views folder is like:
View 6 Replies
View Related
Aug 22, 2011
function func1(str)
{
document.getElementById("txtHint").innerHTML='<Br>Graph type: <select id="sel" name="sel" onchange="func2(str)"><option value="1">1</option><option value="2">
[Code].....
In Above coding,
i want to pass the "str" variable to "func2" in onchange .
but above code is not working.
View 2 Replies
View Related
Mar 3, 2011
if ($page_title->exists()) {
//the rest of the code is in php.here i insert a javascript for the confirm box.
echo'<script type= "text/javascript" >
[code]....
How do I do it?
View 3 Replies
View Related
Mar 27, 2011
I need to include JavaScript variable inside the style tag, how can I do it? I have tried code like below but obviously it doesn't work
Code:
<html>
<head>
<script language="javascript">
function getNumber()
[Code]....
View 2 Replies
View Related
Feb 3, 2011
CDATA-blocks work great for coding large blocks of HTML, or CSS, into strings. But, I can't figure out how to use a variable-value within one.For example, consider this JavaScript code:
var FullName = "Friedrich Hayek";
var ProfileCode = (<><![CDATA[
<div id="BigHonkingChunkO_HTML">
[code]...
How do I get $FullName$ to render as "Friedrich Hayek" instead of "$FullName$"? Note that there is more than one variable and each variable can be used a few times in the CDATA block. Alternate code sample:
var UserColorPref = "red";
var UI_CSS = (<><![CDATA[
body {
[code]....
Looking to set the color attribute to red.
View 2 Replies
View Related
Jan 20, 2010
I have a set or icons that which over time I replace with a different icon and and add a onclick event to them. This is my code
function updateStatusIcons(retText) {
updatingStatuses = true;
var updates = retText.split("|");
for (z=0; z<updates.length; z++) {
[Code]....
Everything works fine except for the onclick event. In the hover message of the icon, the correct project ID is displayed in the message, hoever in the function, the onclick funtion always loads the page with the last set project id. How can I pass the project id into the onclick function and make it stay fixed and not be the value of that it was last set to?
View 2 Replies
View Related
Nov 26, 2010
im trying to change a variable set outside of a function and calling the function with an onchange... i'm having problems getting the variable to change
<script type="text/javascript">
var price = '<?php echo $price; ?>';
function addtwo()
{
if(document.add.size.value == "2xl")
{
price = price + 2;
}
}
</script>
View 4 Replies
View Related