Using a variable in a js function argument
Folks,
This is very basic, but I still cannot get it...
I have this js function in an ASP page:function MM_changeProp(objId,x,theProp,theValue) { //v9.0
var obj = null; with (document){ if (getElementById)
obj = getElementById(objId); }
if (obj){
if (theValue == true || theValue == false)
eval("obj.style."+theProp+"="+theValue);
else eval("obj.style."+theProp+"='"+theValue+"'");
}i don't understand the function, as it was put in automatically by dreamweaver. right now, i am using this onclick event of an image:<div id="apDiv19" onclick="MM_changeProp('apDiv7','','backgroundColor','#FFFF00','DIV')"></div>the #FFFF00 is the color YELLOW. it is being passed to the theValue argument of the js. what i simply want to do is establish a global variable that will house a color string (like #FFFF00), and then use it in the function argument everytime i need the function. something like this:<div id="apDiv19" onclick="MM_changeProp('apDiv7','','backgroundColor',VARIABLE,'DIV')">i do not know how to do two things:
1) initialize and assign the variable a value, and where to establish it (inside the script tags? in the head? in the body?)
2) how to use the variable as an argument in the function
any help greatly appreciated for this novice. thanks!
ajetrumpet wrote:
Folks,
This is very basic, but I still cannot get it...
I have this js function in an ASP page:This forum is not about ASP nor JavaScript. Please use Google to find an appropriate JavaScript forum.
Similar Messages
-
Using a Variable to select a function
Hi there.
I am looking to use a variable that is set when a user clicks
a button to then use as the variable name to call a function. The
actual functions work, but when using a variable as the function
name it doesn't call the function. Here's my code so far, could
anyone help with what I may be doing wrong (please see code snippet
attached).
Thanks a lot
Tony MeadThanks for the reply Dave. I wanted to use a variable because
when any of the 4 buttons are clicked they have to
1. Run the function determined by the closeActive variable
(closing the open panel - could be 1 of 4)
2. open and run a particular panel
Probably best explaind by looking at what I have done so far
(home & about us only at the moment):
http://www.soapbox-creative.com/development/08/index.html
Basically I needed the flash movie to 'know' what panel is
currently opn and when another button is clicked it can just run
the close function and close the panel that is open.
Thanks again
Tony -
Use a variable name within a function?
here's my function....
myInterval = setInterval (TTMO,15);
function TTMO () {
InstanceNameOfMovieClip._x -= (InstanceNameOfMovieClip._x -
_xmouse)/10;
InstanceNameOfMovieClip._y -= (InstanceNameOfMovieClip._y -
_ymouse)/10-2;
instead of using the "InstanceNameOfMovieClip" can i use a
variable name? i've tried, but it doesn't work. i also tried using
the correct hierarchy too, such as this._parent.VariableName
too.you need to concat the linkage to the movieclip using your
string variable like this
var mcName_str = "bigBox_mc";
this[mcName_str]._x = 20;
you can use this method for looping through incrementally
named objects
for(var i:Number=0;i<10;i++)
this["mc"+i]._x = 20;
hope that helped -
Simple Question -- How to use global variables in an another function??!
Function named globalLeftMargin that has:
Global NumberVar LeftMargin := 5;
HOW DO I USE THIS IN ANOTHER FUNCTION? B/C IT DOES NOT RECOGNIZE IT AND GIVES THIS ERROR:
The ) is missing.
The other function is:
Space(LeftMargin)Hi Ajay,
Add WhilePrintingRecords at the beginning of each formula like:
WhilePrintingRecords;
Global NumberVar LeftMargin := 5;
WhilePrintingRecords;
Global NumberVar LeftMargin;
Space(LeftMargin)
Good luck,
Brian -
How to use variable in the LIKE function along with % operators
Hi,
Is there any way i can use the variable in the Like function. That means i have query like
SELECT * FROM Device WHERE DeviceName LIKE %v_MediaName%;
Here "v_MediaName" is the userdefined variable which contains string. I want to retrieve all the records from the "DEVICE" table whose DeviceName LIKE %v_MediaName%;
If i put it in a single quotes '%v_MediaName%' then the v_MediaName will be treaded as a string instead of a variable. I am using this query in a Procedure.
please help me out to resolve the issue.
thanksLIKE '%'||v_MediaName||'%';
Will not make use of the indexes though.
Message was edited by:
satishkandi -
Variable screen in Planning Function for Integrated Planning
Hi all.
I have created a planning application with the WAD, based on an Input_ready Query. Manual planning works fine and even planning functions go well, using the command wizard.
However, if I try to use a variable in a planning function and I set the parameter to pop-up the variable screen within the command wizard for a planning function, I get an 'uncaught exception'. An almost blank IE-window pops up which is supposed to display the variables, but it fails.
Does anybody know how to solve this?
Gr.,
Marc.Hello Marc,
do you still have this error? I encountered the same problem with SPS 9. Maybe you should install at least SPS 10. The variable popup works correct there.
Best regards
Martin -
Using variables for function arguments AS2
Hello,
I am trying to create a function in AS2.
After creating the function, I want to use values stored in variables for the function arguments rather than manually typing static values for carrying out the function calculation. Also, I want to use the function to assign a new value to the existing variable.
I have asked a similar question 2 days ago here and got the answer (thank you), but now I got one more question - How can I create the function to assign a value to the variable while that variable itself is also a function argument?
For example, I have 6 numeric variables:
var CoinA:Number = 10;
var CoinB:Number = 20;
var CoinC:Number;
var CoinD:Number = 30;
var CoinE:Number = 40;
var CoinF:Number;
Then I tried to create a function to assign values to variables CoinC and CoinF:
function CalculationA(FirstCoin, SecondCoin, ThirdCoin):Void {
FirstCoin = SecondCoin + ThirdCoin;
CalculationA(CoinC, CoinA, CoinB);
CalculationA(CoinF, CoinE, CoinF);
The above code didn't really assign the values 30 and 70 to the variables CoinC and CoinF but instead, values of CoinC and CoinF are undefined.
Please give me the correct code if there's a correct way of doing this.
Thank you,Here is one way of doing it, by passing a string value of the variable name instead of the actual variable name....
var CoinA:Number = 10;
var CoinB:Number = 20;
var CoinC:Number;
var CoinD:Number = 30;
var CoinE:Number = 40;
var CoinF:Number;
function CalculationA(FirstCoin, SecondCoin, ThirdCoin):Void {
this[FirstCoin] = SecondCoin + ThirdCoin;
CalculationA("CoinC", CoinA, CoinB);
CalculationA("CoinF", CoinD, CoinE);
(Note that in your second function call I changed the coins since CoinF (ThirdCoin) is undefined at that point.) -
How to use a lexical variable in a WHERE clause and as a function argument.
Hello,
My report has a lexical variable which has values like 'and id in (1,3,4)'. I want to use this variable in two separate queries. In the first, it is used in the WHERE clause, something like:
.. where date is not null &var;
In the second query, the variable is used in a function call, something like:
select * from table (my_function(&var));
The trouble is that the first query works when the value of the variable is unquoted, but for the second query the value should be quoted.
Does anyone have an idea how I could solve this problem?
Thanks in advance,
Frans
Message was edited by:
fransiehttp://tkyte.blogspot.com/2006/06/varying-in-lists.html
Presents many options. -
Weird things happen when using .cfc function arguments
Hey Guys,
I have a function as the following attached code, I can
invoke this function and it works well. but when I change the
number
32144809 to
<cfqueryparam value="#arguments.jpRunNum#"
cfsqltype="cf_sql_integer"> and invoke it by
<cfset qGetJPDependency =
CreateObject("component","cfdocs.imd.criticalPath.components.CriticalPath").test(run_num) >,it
firstly takes a long time waiting without any response, then it
shows a message "Request timed out waiting to execute", I don't how
to explain this, is there anyone know the reason caused this
issue????
Thanks!Have you checked the logs to see what (if anything) else is
being reported
back about this?
Can you check what's going on on the Oracle - am guessing
it's Oracle from
the "CONNECT BY PRIOR" - box @ the time? I presume you can
set it to log
all SQL or JDBC activity?
Are you certain (absolutely ~) that arguments.jpRunNum
contains 32144809,
for the purposes of the test that's failing?
What if you factor the query out into a CF template and run
these tests:
1) as is in your example
2) change 32144809 to use a <cfqueryparam>, but still
hard code the value
to 32144809.
3) set a variable to 32144809, and use the variable as the
value of the
parameter.
From what you're describing, it seems like your query is
getting in a loop,
which with this sort of thing can be down to giving the
CONNECT BY PRIOR a
bung value.
Adam -
How to use the variables of Function exit in the include program
i have a problem of using the variables of a function exit in the include program..
If i use those variables there will be an error indicating 'Field FEBVW_IN is unknown. It is neither in one of the specified tables nor defined by a DATA statement'. Please help... Below is the code of the function exit:
FUNCTION EXIT_SAPLIEDP_202.
""Lokale Schnittstelle:
*" IMPORTING
*" VALUE(IDOC_CONTROL_INDEX)
*" VALUE(IDOC_DATA_INDEX)
*" VALUE(FEBVW_IN) LIKE FEBVW STRUCTURE FEBVW
*" VALUE(FEBKO_IN) LIKE FEBKO STRUCTURE FEBKO
*" VALUE(FEBEP_IN) LIKE FEBEP STRUCTURE FEBEP
*" VALUE(FEBRE_IN) LIKE FEBRE STRUCTURE FEBRE
*" VALUE(FEBPI_IN) LIKE FEBPI STRUCTURE FEBPI
*" EXPORTING
*" VALUE(I_FIMSG) LIKE FIMSG STRUCTURE FIMSG
*" VALUE(FEBVW_OUT) LIKE FEBVW STRUCTURE FEBVW
*" VALUE(FEBKO_OUT) LIKE FEBKO STRUCTURE FEBKO
*" VALUE(FEBEP_OUT) LIKE FEBEP STRUCTURE FEBEP
*" VALUE(FEBRE_OUT) LIKE FEBRE STRUCTURE FEBRE
*" VALUE(FEBPI_OUT) LIKE FEBPI STRUCTURE FEBPI
*" TABLES
*" IDOC_CONTROL STRUCTURE EDIDC
*" IDOC_DATA STRUCTURE EDIDD
*" IDOC_AVIP STRUCTURE AVIP OPTIONAL
*" IDOC_AVIR STRUCTURE AVIR OPTIONAL
*" IDOC_AVIT STRUCTURE AVIT OPTIONAL
*" CHANGING
*" REFERENCE(IDOC_AVIK) TYPE AVIK OPTIONAL
*" EXCEPTIONS
*" PROC_ERROR
INCLUDE ZXF08U10.
Here is the code for the include program.
INCLUDE ZXF08U10
MOVE febvw_in TO febvw_out.Sometimes you will get this error message when checking include code in exits even though there is really no error - it happens because the include does not realise it is in the function due to the navigation index being out of date.
Try activating the code - it may work even though the check said there were errors.
You can also get this issue when trying to drill down on the field in the include to view its structure.
Andrew -
Using environment variable / double quotes in "Arguments" in "Server Start"
I have an admin server, NodeManager, and 1 managed server, all on the same machine (windows). I am trying to enter something similar to this to the arguments field in the Server Start tab:
-Dmy.property=%USERPROFILE%\someDir\someJar.jar
But when the managed server is started it throws this exception:
Error opening zip file or JAR manifest missing : %USERPROFILE%\someDir\someJar.jar
It appears that the environment variable is not being translated into it's value. It is just passed on to the managed server as plain-text. I tried surrounding the path with double quotes (") but the console validates the input and does not allow this: *"Arguments may not contain '"'"*
Even editing the config.xml file manually cannot work, as the admin server fails to startup after this:
<Critical> <WebLogicServer> <BEA-000362> <Server failed. Reason: [Management:141266]Parsing failure in config.xml: java.lang
.IllegalArgumentException: Arguments may not contain '"'.>
I also tried using %20 to no avail, it is just passed as %20.
I thought that perhaps this had something to do with the spaces in the value of %USERPROFILE% (which is "C:\documents and settings.."), but the same thing happens with other env. variables which point to other directories with no spaces.
_My question:_
Is there any supported way of :
using double quotes? what if i have to reference a folder with spaces in it's name?
reference an environment variable? What if i have to rely on it's value for distributed servers where i do not know in advance the variable's value?
Edited by: 937622 on Sep 28, 2012 1:02 AMThere is workaround : http://stackoverflow.com/questions/12629395/weblogic-using-environment-variable-double-quotes-in-arguments-in-server
Just posting here for reference. Let's see if we get a different answer from anyone else. -
How to use data function using characterstics variable for calculation on
how to use data function using characterstics variable for calculation on attribute as key figure
Hi Gayatri
Did you not see my answer for CASE because CASE does indeed offer the use of the BETWEEN clause, but DECODE does not. Let me give you a little synopsis of DECODE.
In its most simple form it takes 4 values and looks like this: DECODE(A, B, C, D)
This essentially means, IF A = B THEN C ELSE D
The trick to solving BETWEEN in a DECODE is to work out algoriths where A = B. Because we don't know how many values are between 00 and 99, although I could guess there were 100 we could of course have 100 parts in the DECODE but that would be awful. How about if we look at it another way and say this:
IF PART_NUMBER < 'SDK00' THEN pay_amount
ELSE IF PART_NUMBER > 'SDK99' THEN pay_AMOUNT
ELSE pay_amount + 100
This statement only had 2 hard coded values, but how to make DECODE work with less than? Easy, we use the LEAST function. The LEAST function takes 2 values and returns the one with the lowest value. So I use LEAST(PART_NUMBER, 'SDK00') then whenever the PART_NUMBER is lower than SDK00 it will be true. A similar situation exists for the opposite function GREATEST. Putting all of this together then, you can do this:
DECODE(PART_NUMBER, GREATEST(PART_NUMBER, 'SDK00'), DECODE(PART_NUMBER, LEAST(PART_NUMBER, 'SDK99'), PAY_AMOUNT * 100, PAY_AMOUNT), PAY_AMOUNT)
In English this can be read as follows:
IF the PART_NUMBER is greater than or equal to SDK00 and the PART_NUMBER is less than or equal to SDK99 THEN PAY_AMOUNT x 100 ELSE 0
Best wishes
Michael -
Use Formula variable in planning function
Hello,
I would like to use a formula variable in a planning function.
The problem is that when I execute this function all keyfigures values are set to 0 so the FOX is not executed.
The idea is to have something like
= VARV(FORMULAVARIABLE).
How could this be achieved using FOX ?
Or how using an exit function could I call this FORMULAVARIABLE which is not used in the query ?
Thanks,
MatthieuHello Matthieu,
Please search the forum before posting:
http://forums.sdn.sap.com/click.jspa?searchID=70350665&messageID=9814615
Regards,
Marc
SAP Techology RIG
PS: You closed the thread so I have to add some details here. The FOX runtime is hardcoded to 0RSPLS_FORMULA. Therefore, 0RSPLS_FORMULA cannot be copied to a custom planning function type as you suggest.
Edited by: Marc Bernard on Feb 23, 2011 3:36 PM -
Do not use bind variable notations for p_session_id argument...
Hi there,
... in apex_custom_auth.login the Apex doc says. Does anyone know why not?
LOGIN Procedure
Also referred to as the "Login API," this procedure performs authentication and session registration.
p_session_id Current Oracle Application Express session ID.
Note: Do not use bind variable notations for p_session_id argument.Thanks
LuisI tend to avoid assigning values to bind variables like that - but it may be due to the nature of much of my code residing in PL/SQL packages.
And due to the strange encounters I have had with this, like your linked discussions, I've tended towards using apex_util instead.
You may also enjoy this discussion
http://www.danielmcghan.us/2012/08/implicit-commits-in-apex.html
Scott -
Using value variables throw public functions
He all!!
I'm trying to use value variables throw public functions in
the same class.
Is there any possible to do it?
I'll explain:
What i whant is in tha FLA file to get the songName of the
mp3 like trace(musica.nomeMusica);
quote:
//AS Code
package Mp3Player{
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.media.SoundChannel;
import flash.media.ID3Info;
import flash.net.URLRequest;
import flash.events.Event;
public class Mp3Player {
private var sound:Sound;
private var req:URLRequest;
private var context:SoundLoaderContext;
private var channel:SoundChannel;
private var id3:ID3Info;
private var nomeMusica:String;
public function tocarMusica(file) {
sound=new Sound ;
req=new URLRequest(file);
context=new SoundLoaderContext(8000,true);
sound.load(req,context);
channel=sound.play();
trace("A tocar");
sound.addEventListener(Event.ID3,id3Info);
public function id3Info(event:Event):void {
id3=event.target.id3;
nomeMusica=id3.songName;
public function get getNome():String {
return nomeMusica;
//FLA Code
import Mp3Player.Mp3Player;
var musica:Mp3Player = new Mp3Player();
var nome:String = musica.getNome;
musica.tocarMusica("Saia_Indiscreta.mp3");
trace(nome);
The trace of my code is:
quote:
A tocar
Null
What i'm doing wrong or is missing?Tnks all for the reply but none of them give me any answer :(
Making the question in other way.
Using the code above, how can i set a funcion to call the
musicaNome value from FLA file?
quote:
//AS Code
package Mp3Player{
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.media.SoundChannel;
import flash.media.ID3Info;
import flash.net.URLRequest;
import flash.events.Event;
public class Mp3Player {
private var sound:Sound;
private var req:URLRequest;
private var context:SoundLoaderContext;
private var channel:SoundChannel;
private var id3:ID3Info;
private var nomeMusica:String;
public function tocarMusica(file) {
sound=new Sound ;
req=new URLRequest(file);
context=new SoundLoaderContext(8000,true);
sound.load(req,context);
channel=sound.play();
trace("A tocar");
sound.addEventListener(Event.ID3,id3Info);
public function id3Info(event:Event):void {
id3=event.target.id3;
nomeMusica=id3.songName;
Maybe you are looking for
-
Will the Apple mini DVI to video adapter work with a macbook? What to Buy?
I went to my local Apple Reseller and asked for a mini dvi to video adapter to use to connect my macbook to a tv using either s-video or the yellow RCA cable. I was told that they only had the one that was for an ibook and Power book and that this wo
-
27" iMac with SSD only: can you add a Hard drive later on?
I'm thinking of ordering a BTO 27" i7 iMac with onl the SSD, but am wondering if it will then have the internal brackets or space to take a secondary hard drive should I choose to install one later on? Yes, I'm comfortable opeing up an iMac. I consi
-
How to use analytical functions inside a mapping
Hello everybody. Here Isend you a trick that we are using for two years. If you want to use a function (for instance :ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...)) inside a mapping you must create an expression with in the INGRP1 the fields you
-
N95 turn flash light on,and can't turn it off- Pro...
Hi, I have N95-1 firmware v21.0.016. I didn't decide yet to update new v30, because some reviews I thought that it's better to skip this and wait next. The problem I experience with my device is that some time (it's happened few times) in ordinary us
-
Backup failed error code o8x100037
any ideas?