PDA

View Full Version : Mivascript and javascript


Scot - ScotsScripts.com
05-17-06, 10:21 PM
Anyone know how to reference javascript variables with mivascript?

Scot

aGorilla
05-17-06, 10:38 PM
Anyone know how to reference javascript variables with mivascript?
Could you elaborate on that?

Kent Multer
05-17-06, 10:59 PM
Miva Script runs on the server, and JavaScript on the browser, so they can't just "reference" each other like normal programming languages. Here's the short version:

1. Miva Script can manipulate the browser environment by including JavaScript code in its output. So for example, you can create a JavaScript variable with the same name as a Miva variable like this:

<MvEVAL EXPR="{ 'var myVariable =' $ g.myVariable $ '; ' }">

More advanced uses often result in bewildering mazes of quotes and brackets, but you can do some pretty clever things if you're careful. Of course, when the JavaScript changes these values, the change is NOT automatically sent to the server.

2. JavaScript can send data back to the Miva environment by putting it in form fields and submitting the form, or by adding parameters to a URL and then calling it. Sometimes you end up including hidden fields in a page without specifying a value; the fields are just there so that a JavaScript can put data into them later.

Hope that helps --

Scot - ScotsScripts.com
05-22-06, 08:14 PM
Thanks- I didn't think of the url or form variable options. That's how I get flash to interact with miva script, should have known javascript could do it that way as well.

Thanks for the response-

Scot