Using javascript variable in spry if statement

is it possible to put a javascript variable in to the spry if
statement to test?
like <div spry:if="javascriptvar == {ds_RowNumber}"....
thanks.

Hi rogerfreak,
When the region processes a spry:if, it simply takes the
value of the spry:if attribute, replaces all of the data references
in it with real values from the data set and then evals the result
(executes the string).
So you can do something like:
<script>
var ds1 = new Spry.Data.XMLDataSet("foo.xml", "/foo/bar");
var gMode = 5;
function GetMode()
return gMode;
</script>
<div spry:region="ds1">
<ul spry:if="gMode == 5">
<li spry:repeat="ds1">{name}</li>
</ul>
<div spry:if="gMode == 12" spry:repeatchildren="ds1">
{name}
</div>
</div>
In the example above the list markup will be written out if
gMode is 5, but if it is 12, it will write out the div markup.
You can also call functions:
<div spry:region="ds1">
<ul spry:if="GetMode() == 5">
<li spry:repeat="ds1">{name}</li>
</ul>
<div spry:if="GetMode()== 12"
spry:repeatchildren="ds1">
{name}
</div>
</div>
--== Kin ==--

Similar Messages

  • Using a variable in Spry conditional tests included in a Spry Tooltip

    I have the following code:
    <div spry:region="company" id="tooltip">
    <div spry:repeat="company" spry:choose="spry:choose">
    <div spry:when="'{name}'==memberName">
    <table>
    <tr>
    <td
    align="center"><h2>{name}</h2></td>
    </tr>
    <tr>
    <td align="center"><img src="{headshot}"
    alt="{name}" width="227" height="350" /></td>
    </tr>
    <tr>
    <td align="center">{description}</td>
    </tr>
    </table>
    </div>
    </div>
    </div>
    <script type="text/javascript">
    var tooltip_trigger_one = new
    Spry.Widget.Tooltip("tooltip","#trigger", {showDelay: 200,
    hideDelay: 200, offsetX: 250, offsetY: 200} );
    </script>
    where the variable "memberName" is set elsewhere to a value
    that matches one of the occurrences in the column "name" in the
    dataset "company". I can see, using debugging tools, that the
    variable is being set correctly. But.... when the tooltip is
    triggered, only a small few-pixel square box opens up.
    If, instead of using the variable "memberName" in:
    <div spry:when="'{name}'==memberName">
    I use a string, as in
    <div spry:when="'{name}'=='John Doe'">
    then the code works correctly and I get a large tootlip
    showing me the correct information for that member of the company.
    I have tried different tests (spry:if and spry:test for
    instance), tried various combinations of quotes and parenthesis and
    tried placing the code at various places both inside and outside of
    the <body> -- but always get the same results.
    Is it not possible to test against a variable or am I doing
    something else incorrectly?
    Thanks,
    Janet

    OK.... some progress to report.
    I was setting memberName onmouseover-- which is also the
    trigger for the tooltip-- thusly:
    <p><em onmouseover="memberName='John Doe'"
    id="trigger">John Doe</em></p>
    It seems that the variable is being set, but too late, as the
    trigger has already caused the div... id="tooltip"> to be
    evaluated with "memberName" not equal to any of the names in the
    dataset. I tried using a function call to set "memberName" and
    tried putting the onmouseover in the <p> tag and leaving the
    trigger id in the <em> tag. but neither of those appear to
    change the outcome. "memberName" still appears to be set to the
    value I initialized it to up the the <head> section at the
    time the tooltip <div> is evaluated. Although it is set
    correctly if I check it's value using Firebug after I have
    mouse-overed it.
    Incidentally, using a Firebug breakpoint just before the
    <div spry:when...> and checking the value of memberName was
    how I discovered that "memberName" still seemed to have a value of
    "initialized" which is what I set it to up in the <head>
    section.
    Having written all of this, I am wondering though, shouldn't
    the value of "memberName" be equal to "John Doe" the second time I
    mouseover it? Or, if there are more than one trigger "names" on the
    page, shouldn't "memberName" be equal to the name of the previous
    trigger that I moused-over? And with memberName having a legitimate
    value at that point, shouldn't the tooltip now show the correct
    display information rather than just that little few pixel square
    box that I am getting when I mouse-over the trigger name?
    Clearly there is something that I just am not understanding.
    Janet

  • How do I use a variable within a sql statement

    I am trying to use a local variable within an open SQL step but I keep getting an error.
    My sql command looks like this "SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " +  locals.CurrentSerialNo
    If I replace the locals.CurrentSerialNo with an actual value such as below the statement works fine.
    "SELECT BoardDetailID FROM BoardDetails WHERE SerialNumber = " +  " 'ABC001' " 
    Can someone tell me how to correctly format the statement to use a variable?

    Hi,
    Thanks for the reply. I have changed the required variable to a string, but with no success. I have reattached my updated sequence file and an image of the error.
    When looking at the Data operation step I see that the sql statement is missing everything after the last quotation mark.
    Thanks again,
    Stuart
    Attachments:
    Database Test Sequence.seq ‏10 KB
    TestStand error.JPG ‏37 KB

  • How to use presentaion variable in the SQL statement

    Is there any special syntax to use a presentation variable in the SQL Statement?
    I am setting a presentation variable (Fscl_Qtr_Var)in the dashboard prompt.
    If i set the filter as ADD->VARIABLE->PRESENTATION, it shows the statement as 'Contract Request Fiscal Quarter is equal to / is in @{Fscl_Qtr_Var} '.
    And this works fine but when i convert this to SQL, it returns
    "Contract Request Date"."Contract Request Fiscal Quarter" = 'Fscl_Qtr_Var'
    And this does not work.It is not being set to the value in the prompt.
    I need to combine this condition with other conditions in the SQL Statement. Any help is appreciated. Thanks

    Try this: '@{Fscl_Qtr_Var}'

  • How to use javascript variable in BSP/ABAP and vice versa

    Hello Experts,
    In IC WEBCLIENT, there is a view.In the view.htm i want to fetch  the screen resolution and as per the resolution i want set the width of that view.
    1, I wrote the below  javascript to fetch the screen resolution.
       Can i use a notmal ABAP variable inside the javascript? and   If i use can i access that variable after the javascript.?
       Can i assign a javascript variable to a nrmal abap variable??
       The code sample  is like :
    Start of javascript
       if (screen,width == 1024 )
         lv_width = 500  "lv_width is an ABAP variable.
      else
        lv_width = 700
    **END OF JAVASCRIPT
       **Now i want to use lv_width  to assign to a table view attribute(Width)
    <crmc: tableview..
                    width = <%= lv_width >
    the code is not giving any error. But the problem is that lv_width is not giving the correct value, its getting initialized to initial value...
    Requesting the experts to please provide some suggestions/solution for the above issue.
    Thanks and Regards
    Sudhansu

    Hello Sudhansu,
    First of all there was a little mistake at my previous answer:
    you got lw_width = 700
    because at Server Side you have following code:
    lw_width = 500.
    lw_width = 700.
    but if you were writing your code like this:
    <%=lw_width %> = 700.
    then you will get the result that I was talking about : 0 = 700
    Sorry for the mistake
    Now for your question:
    if you want to get a value from the server and assign it to JScript variable you should write like this :
    var aaa;
    aaa = <%=lw_width %>;
    this code assign the server variable lw_width value into aaa  JScript varible.
    I'm not sure what exactly you want to do but look at this link:
    http://www.pageresource.com/jscript/jscreen.htm
    to get the idea how to get and use Screen Resolution variables at your JScript code.
    Good luck
    Eli Steklov
    Please Reward Points if it Helped

  • How to use bind variable in this select statement

    Hi,
    I have created this procedure where table name and fieldname is variable as they vary, therefore i passed them as parameter. This procedure will trim leading (.) if first five char is '.THE''. The procedure performs the required task. I want to make select statement with bind variable is there any possibility to use a bind variable in this select statement.
    the procedure is given below:
    create or replace procedure test(tablename in varchar2, fieldname IN varchar2)
    authid current_user
    is
    type poicurtype is ref cursor;
    poi_cur poicurtype;
    sqlst varchar2(250);
    THEVALUE NUMBER;
    begin
         sqlst:='SELECT EMPNO FROM '||TABLENAME||' WHERE SUBSTR('||FIELDNAME||',1,5)=''.THE ''';
         DBMS_OUTPUT.PUT_LINE(SQLST);
    OPEN POI_CUR FOR SQLST ;
    LOOP
         FETCH POI_CUR INTO THEVALUE;
              EXIT WHEN POI_CUR%NOTFOUND;
              DBMS_OUTPUT.PUT_LINE(THEVALUE);
              SQLST:='UPDATE '||TABLENAME|| ' SET '||FIELDNAME||'=LTRIM('||FIELDNAME||',''.'')';
              SQLST:=SQLST|| ' WHERE EMPNO=:X';
              DBMS_OUTPUT.PUT_LINE(SQLST);
                   EXECUTE IMMEDIATE SQLST USING THEVALUE;
    END LOOP;
    COMMIT;
    END TEST;
    Best Regards,

    So you want to amend each row individually? Is there some reason you're trying to make this procedure run as slow as possible?
    create or replace procedure test (tablename in varchar2, fieldname in varchar2)
    authid current_user
    is
       sqlst      varchar2 (250);
       thevalue   number := 1234;
    begin
       sqlst := 'update ' || tablename || ' set ' || fieldname || '= ltrim(' || fieldname || ',''.'')  where substr(' || fieldname
          || ',1,5) = ''.THE ''';
       dbms_output.put_line (sqlst);
       execute immediate sqlst;
    end test;will update every row that satisfies the criteria in a single statement. If there are 10 rows that start with '.THE ' then it will update 10 rows.

  • Using toUpperCase variable in an If Statement

    Hi all,
    I am monitoring a user's input in my command-line program, and by converting their input to upper case, I can easily check whether they've input the correct string. However when I use the String in an If statement, it doesn't like it. Here's the simple test code I've been using:     public static void main(String[] args) {     
    BufferedReader keyboardInput = new BufferedReader(new InputStreamReader(System.in));     
    String priceOfPlayers = null;
    try  {
         System.out.print("Price Of Players: ");
         priceOfPlayers = keyboardInput.readLine();
         priceOfPlayers = priceOfPlayers.toUpperCase();                         
         System.out.println(priceOfPlayers);          
         if (priceOfPlayers != "ORIGINAL PRICE" && priceOfPlayers != "CURRENT PRICE") {
              System.err.println("\nYou Have Entered An Invalid Option!\n");          
         } catch (Exception e) {
              e.printStackTrace();
              System.exit(1);
         }However if I type in say 'original price' or 'current price' or 'ORIGINAL PRICE', it still brings up the error message that I have written! I do not understand why it doesn't interpret the String value properly.
    Any help explaining this would be superb!
    thanks

    Hi
    String comparison should use the equals method instead of ==
    if (!priceOfPlayers.equals("ORIGINAL PRICE") &&  !priceOfPlayers .equals("CURRENT RICE")) {
              System.err.println("\nYou Have Entered An Invalid Option!\n");          
         }

  • Re:using javascript variable in jstl tag

    Hi,
    Can we access javascript variable in a jstl tag..
    For example
    function clickGroupByPO()
    var brand="hello";
    <c:set var="Var" value="${brand}" />
    alert("${Var}");
    I am geeting balnk in the alert.. I want to assign brand to value attribute in <c:set>
    Thanks and Reagrds,
    radha

    Doublepost, please proceed here: http://forum.java.sun.com/thread.jspa?threadID=5233323

  • Using sql:variable in an insert statement

    I'm writing an insert statement for a table with an XML column.  Most of the XML is static, but I need to replace the value of an element with the value of a T-SQL variable, as shown here:
    CREATE TABLE [dbo].[OrderDetail](
    [OrderID] [int] NULL,
    [OrderDetail] [xml] NULL
    GO
    DECLARE @XMLData XML;
    DECLARE @ItemID INT;
    SET @ItemID = 1000;
    SELECT @XMLData = N'
    <OrderDetail xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    </OrderDetail>
    SET @XMLData.modify('insert <ItemID>[sql:variable("@ItemID")]</ItemID> into (/OrderDetail)[1]')
    INSERT INTO [dbo].[OrderDetail] ([OrderID], [OrderDetail])
    VALUES (@ItemID, @XMLData);
    When I run this, it inserts "[sql:variable("@ItemID")]" instead of the value of @ItemID.  If someone could show me the proper syntax, I would really appreciate it.  Thanks.

    Yes, that worked.  Now I want to change it a little.  I also have an attribute that I need to update with the value of a variable.
    DECLARE @XMLData XML;
    DECLARE @SetID INT;
    DECLARE @SetIDStr VARCHAR(12);
    DECLARE @SetIDXML XML;
    SET @SetID = 9999;
    SET @SetIDStr = CONVERT(VARCHAR(12), @SetID);
    SET @SetIDXML = CONVERT(XML, @SetIDStr);
    SELECT @XMLData = N'
    <OrderDetail xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ItemID>1000</ItemID>
    <RightOperand ID="15524" Name="ItemName" Value="15524" />
    </OrderDetail>
    SET @XMLData.modify('replace value of (/OrderDetail/RightOperand/@ID)[1] with sql:variable("@SetIDXML")');
    INSERT INTO [dbo].[OrderDetail] ([OrderID], [OrderDetail])
    VALUES (@SetID, @XMLData);
    SELECT * FROM [dbo].[OrderDetail];
    I'm trying to replace "ID="15524"" with the value of @SetID.  This code throws an exception:
    Msg 9342, Level 16, State 1, Line 23
    XQuery [modify()]: An XML instance is only supported as the direct source of an insert using sql:column/sql:variable.
    Thanks again for your help.

  • How do I use bind variables for the SQL statements having IN clause

    SELECT id, name FROM t
    WHERE id in (10,20,30)
    As the IN list will have 'n' number of values, I am not able to specify fixed number of bind
    variables like
    SELECT id, name FROM t
    WHERE id in (?,?,?....)

    452051 wrote:
    I am not able to specify fixed number of bind variablesYou could use collection:
    SQL> create or replace force
      2    type NumList
      3      as
      4        table of number
      5  /
    SQL> select ename from emp where deptno member of NumList(10)
      2  /
    ENAME
    CLARK
    KING
    MILLER
    SQL> select ename from emp where deptno member of NumList(10,20,30)
      2  /
    ENAME
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    SCOTT
    KING
    TURNER
    ADAMS
    ENAME
    JAMES
    FORD
    MILLER
    14 rows selected.
    SQL> This way you have one bind variable - collection.
    SY.

  • Using Javascript variable in JSP

    I m setting a variable named btn to the value of the button which was clicked but the problem here is that i m nt getting its value whn i want to set it to a request.setAttribute() method.

    > Yes... nw i get the prob... thanx yaar .... bt cn u
    suggest me wht cn i do fr this situation
    My first suggestion, beyond all others, is to use real words. Your writing is practically unintelligible.
    Please make the extra effort to write out words such as "now", "problem", "thanks", "but", "can", "you", and "for" (I have no idea what "yaar" means). The extra keystrokes won't cost much in the way of time, and the enhanced clarity will be appreciated by those communicating on a forum with international readership. Also, it will give the appearance that you take your question seriously, which will in turn make your question look more interesting to answer.
    ~

  • Cannot use sqlplus variable in create sequence statement

    Hello!
    I would like to create a sequence object starting with a number retrieved from a select statement:
    var max_resp_no number;
    begin
    select max(substr(resp_no,2)) into :max_resp_no from brc_mast
    where substr(resp_no,1,1)='Z';
    end;
    print max_resp_no;
    drop sequence p659_resp;
    create sequence p659_resp start with :max_resp_no;
    It tells me that :max_resp_no is an 'invalid number';
    TIA,
    habeeb

    You need to do this entirely in PL/SQL. You can either create a procedure, or use an anonymous block. The procedure version is below. Just change the CREATE to a DECLARE to get an anonymous block.
    CREATE OR REPLACE PROCEDURE new_seq IS
    max_resp_no NUMBER;
    BEGIN
    SELECT to_number(MAX(SUBSTR(resp_no,2)))
    INTO max_resp_no
    FROM brc_mast
    WHERE SUBSTR(resp_no,1,1)='Z';
    EXECUTE IMMEDIATE 'DROP SEQUENCE p659_resp';
    EXECUTE IMMEDIATE 'CREATE SEQUENCE p659_resp START WITH '|| max_resp_no;
    END;
    SQL> CREATE SEQUENCE p659_resp START WITH 1;
    Sequence created.
    SQL> SELECT p659_resp.nextval from dual;
       NEXTVAL
             1
    SQL> SELECT * FROM brc_mast;
    RESP_
    Z001
    Z002
    Z003
    Z075
    SQL> exec new_seq;
    PL/SQL procedure successfully completed.
    SQL> select p659_resp.nextval from dual;
       NEXTVAL
            75Note that the user creating this procedure will need to have CREATE SEQUENCE granted explicitly for the procedure to work. The anonymous block version should work if CREATE SEQUENCE is granted through a role.
    John

  • Using a number variable in an SQL statement

    Hi,
    I am trying to use a variable in an sql statement and I have run into problems when the variable is a number. The following line of code works if the variable is a string but not if it is a number.
    "SELECT TOP 1 UUT_STATUS FROM UNIT_UUT_RESULT WHERE UnitID =  '" + Locals.LocalUnitID + "' ORDER BY START_DATE_TIME DESC"
    Is there a difference in the use of the single and double quotes and the + sign for number variables?
    Thanks
    Stuart
    Solved!
    Go to Solution.

    Hi Stuart,
    I am assuming that the UnitID is stored as a numeric in the database? If so, the proper SQL syntax for comparing with numerics should not use a single quote (or any quotes for that matter). The quotes are used only for strings.
    So you would want to use:
    "SELECT TOP 1 UUT_STATUS FROM UNIT_UUT_RESULT WHERE UnitID =  " + Locals.LocalUnitID + " ORDER BY START_DATE_TIME DESC"
    This is really more of an SQL question universal to all languages, not just TestStand.
    Here is an excellent resource that you can consult:
    http://www.w3schools.com/sql/sql_where.asp
    Jervin Justin
    NI TestStand Product Manager

  • [php+mysql] how to use variables in a select statement?

    Hi all,
    I'm searching for a way to use a variable in the select
    statement of mysql
    query.
    I have this variable that can contain:
    $var=field_1 field_2 field5
    or
    $var=field3 field4 field8
    so, the variable content is not always the same.
    I would like to filter a table selecting only the columns
    specified by the
    current $var content.
    Is this possible to do something like this?
    $var=field1 field5 field10
    SELECT string_to_array($var)
    FROM mytable
    ORDER BY mysortfield ASC
    Or, is there another way to select columns dynamically?
    Thanks for any suggestion.
    tony

    Hi all,
    I'm searching for a way to use a variable in the select
    statement of mysql
    query.
    I have this variable that can contain:
    $var=field_1 field_2 field5
    or
    $var=field3 field4 field8
    so, the variable content is not always the same.
    I would like to filter a table selecting only the columns
    specified by the
    current $var content.
    Is this possible to do something like this?
    $var=field1 field5 field10
    SELECT string_to_array($var)
    FROM mytable
    ORDER BY mysortfield ASC
    Or, is there another way to select columns dynamically?
    Thanks for any suggestion.
    tony

  • Using Presentation variables..along with case statements..

    Hi All.
    I have a issue using presentation variable along with CASE statements. My approach is
    1) I have a dashboard prompt, which is being set as Presentation variable.
    Based on the value selected in prompt, for ex the values of prompt can be 'ABC' and 'DEF'.
    I have a calculated column, the calculation goes this way...
    The forumal is
    CASE WHEN @{Presentation Variable Name} = 'ABC' THEN xxxxxxxxxx ELSE IF @{Presentation Variable Name} = 'DEF' END. It gives error of "no table being referenced"..
    Is this is the right approach??
    Can i get the values of variable in a column formula, so that a column can have values selected in prompt?
    Can anybody pls help me here..
    Thanks in advance...

    Hi
    Thanks for the quick response..
    I agree to ur point..
    But the requirement is
    Based on the value of the prompt I need to switch the calculation in one of the formula area of one column..
    If Prompt value is ABC then one kind of calculation in Fx and If the prompt value is DEF then one kind of calculation in the same Fx..
    How can I acheive this?
    Thanks in advance..

Maybe you are looking for

  • Itunes wont recognize I-pod

    Hello, I recently just bought a I-pod nano(3rd generation) and everytime i plug my I-pod in the computer it wont come up in itunes but shows under my computer and a message comes up called _IpodService Module_ saying that i-pod service module has eco

  • Loop  wirh for using case when

    Hello, i wanna use a loop over a select but this select depend on a variable value so, here is what i did: CREATE OR REPLACE Procedure dispatch_pat(perId in number,shortlist_ID in number,orId in number, typeDonnee in number) is orVar number(7); test

  • Reader-enabled fillable form is corrupted on Mac

    I created a Reader-enabled (extended) fillable form that can work fine if filled out in and saved in Reader. But some users are opening and filling out the form in their browser. When it is returned  to me, it is unopenable. If the form is forwarded

  • Photoshop Elements--No Organizer

    After installing a paid-for version (Dec. 1, 2012)  of Elements 11, my Organizer stopped working. It fails to boot up--no windows, nothing except the words ORGANZIER on the top menu bar. And when I look at the icon for the Organizer in my iMAC applic

  • MY webcams not working on my new HP B960 Pavilion

    I just bought this the other day but when i try to use the webcam an error message comes up, please can someone help me with this problem, thanks in advance