Welcome to TalkGraphics.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2000
    Location
    Beaverton, OR
    Posts
    3,267

    Question [Question] - use of variables in Javascript for XWD

    In Javascript is there a way to create a "dynamic" variable which recognizes the page it is located on and then be able to refer (call) it in other scripts or links?

    I don't know the proper programming terms, so bear with me.

    So, for instance, in the Website Tracker code you define a global dynamic variable called [vCurrentPg].

    Then that variable would be used as part of a name, ie.,...Zebra_[vCurrentPg]. When viewing or publishing, XWD would read page-1 and internally interprets the name as Zebra_1. If the name were used on page-9, internally it interprets the name as Zebra_9.

    Similarly, a link could be created referencing this name, for instance ...'javascript:my_close('Zebra_[vCurrentPg])'.

    The Name dialog dropdown list would display Zebra_[vCurrentPg].

    Such a variable could be used for displaying page numbers or other page unique functions.

    It would be helpful when creating names in complex, multipage sites and pare-down the Names' list.

    JC
    Last edited by jclements; 15 March 2009 at 09:49 PM.
    IP

  2. #2
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: [Question] - use of variables in Javascript for XWD

    I'mnot quite sure if I get you right. But, if I do, simply add something like this to every page:
    Code:
    <script type="text/javascript">var vCurrentPg=1;</script>
    replace 1 with the page number.
    Then the script can use this to identify a page.
    John.
    IP

  3. #3
    Join Date
    Aug 2000
    Location
    Beaverton, OR
    Posts
    3,267

    Default Re: [Question] - use of variables in Javascript for XWD

    I guess I haven't done a good job of explaining my concept. Let me see if I can think a better of better way of explaining.

    = = = = = = = = = = = = =

    Think of an oldtime word processor where you could insert a page code symbol in a header. Lets pretend that symbol is "#". Although when you look at header of any page all you see is the # symbol, the correct page number is printed.

    In the example above for XWD, you put the javascript code to define variable "#" in the webtracker; # is able to decipher the page number of any page it is placed on. On page one, you create a shape and assign it a name of "Zerba#" . You create a button with the java script ..'javascript:my_close('Zebra#)'. Now you duplicate the page. On page one , the button's javascipt would be interpreted as, 'javascript:my_close('Zebra1)' and the shape's name would be interpreted as, Zebra1. On page two, the button's javascipt would be interpreted as, 'javascript:my_close('Zebra2)' and the shape's name would be interpreted as, Zebra2.

    = = = = = = = = = = = = =

    Perhaps another analogy would be the Link to Page variables shown in the dropdown list of the Web Properties Dialog, Link Tab, <Next page> and <Previous page. Let us assume there is also one called <Current page>. What I would like to be able to do is create a Name in which <Current page> is a part the name, such as: "Zebra<Current page>" and assign that name to an object. The button linking to that object has a javascript that might look like this, javascript:my_close('<Current page>'). If you were to look at the name and web properties of the pair on any page they would look the same, Zebra<Current page> and javascript:my_close('<Current page>'), but when publishing or viewing XWD would, behind the scenes, substitute <Current page> with a value of the active page.
    Last edited by jclements; 15 March 2009 at 10:59 PM.
    IP

  4. #4
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: [Question] - use of variables in Javascript for XWD

    Aha... Now it looks like a request for some sort of preprocessor. This can't be done in JS.
    John.
    IP

  5. #5
    Join Date
    Aug 2000
    Location
    Beaverton, OR
    Posts
    3,267

    Default Re: [Question] - use of variables in Javascript for XWD

    I appreciate your time to evaluate. Thank you.

    JC
    IP

 

 

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •