I can set and get the value the usual jQuery way (DOM traversal and setting
attributes, etc.) and I can return variables from the server and pass them
back into an AJAX function for use.

I was just hoping for some way to avoid having to
pass variables between sections of code.  I'd rather, at this point at least,
just set a global variable for use on a page and refer to it wherever
I need it, without having to reference some value in another piece of code.

Traversing the DOM to obtain values can get old.  And when those variables get
passed around a lot, tracking where they've been and when they may have
gotten changed is a pain.  With a well-named global variable, using 
name-spacing,
I can set a global variable and use it and avoid collision.

It appears that's just a characteristic of JS that variables can be referenced
so easily.  Thanks for the info.  I haven't found any solutions or info that 
make
me believe it doable, anyway.  So, back to passing variables around the DOM.

Rick

-----Original Message-----
From: jquery-en@googlegroups.com [mailto:jquery...@googlegroups.com] On Behalf 
Of brian
Sent: Tuesday, April 07, 2009 12:10 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: How do I access global variables for id's, etc.?


I don't think it's the quotes that are the problem. Those are, after
all, perfectly legitimate characters within a tag. Now, script tags,
OTOH ...

Why don't you just use something server-side?

On Tue, Apr 7, 2009 at 11:53 AM, Rick Faircloth
<r...@whitestonemedia.com> wrote:
> I would like to be able to do something as simple as
>
> <p id=”<script>myGlobalVariable</script>”>xyz</p>,
>
> but apparently the “” marks are a problem.
>
>
>
> I’m able to output a global variable value like this:
>
> <p>The value of myGlobalVariable is <script>myGlobalVariable</script>.</p>
>
>
>
> Is there some way to use global variable values with an id attribute?
>
>
>
> Thanks,
>
>
>
> Rick
>
>
>
> ---------------------------------------------------------------------------------------------------------------------------------------
>
> "It has been my experience that most bad government is the result of too
> much government." - Thomas Jefferson

Reply via email to