You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Steve O'Hara <so...@pivotal-solutions.co.uk> on 2005/06/24 18:10:29 UTC

RE: Help me - how to pass retreived database values toJavascript

This is starting to get a bit off-topic but what I think you're alluding to
"Associatve Arrays" (collections by any other name)
Here's an example of how to use them.


<html>
<head>
<script>
var myarray={
#foreach ($item in $list)
'text$velocityCount':'$item',
#end
}
</script>
</head>
<body>

<form name="steve">
<input type="text" name="text1" size="20"><br>
<input type="text" name="text2" size="20"><br>
<input type="text" name="text3" size="20"><br>
<input type="text" name="text4" size="20"><br>
<input type="text" name="text5" size="20"><br>
</form>

<button onclick="document.steve.text4.value=myarray['text4']">Click here to
assign a value to a box using it's name</button>

</body>
</html>



-----Original Message-----
From:
velocity-user-return-16266-sohara=pivotal-solutions.co.uk@jakarta.apache
.org
[mailto:velocity-user-return-16266-sohara=pivotal-solutions.co.uk@jakart
a.apache.org]On Behalf Of Veerappan Sridhar
Sent: 23 June 2005 16:34
To: velocity-user@jakarta.apache.org
Subject: RE: Help me - how to pass retreived database values
toJavascript


Hi ,
thanks for ur reply.thank u very much,pls give a solution for the below
problem.
 That retreive problem is solved. I want one more help from u guys.

      In velocity page i have an array of text box, how to pass and to
get the text box(i) value in javascipt and in which event i can do.
      if i do in submit event all the text box values will be
processed, i dont need that, onblur event i have to check,but how i
can
identify in javascript which text box is being used.

for example: i am in text box(3) , entering some value in javascript i
have to get text box3 values

So pls help me
Sridhar


>>> sohara@pivotal-solutions.co.uk 06/23/05 9:03 PM >>>
I'm guessing that you're trying to do something like this;

<script>
var myarray=[
#foreach ($item in $list)
'$item',
#end
]
</script>


This creates a javascript array (the last element is empty, but you get
the
idea).

Steve




-----Original Message-----
From:
velocity-user-return-16262-sohara=pivotal-solutions.co.uk@jakarta.apache

.org
[mailto:velocity-user-return-16262-sohara=pivotal-solutions.co.uk@jakart
a.apache.org]On Behalf Of Barbara Baughman
Sent: 23 June 2005 16:05
To: Velocity Users List
Cc: velocity-user-help@jakarta.apache.org
Subject: Re: Help me - how to pass retreived database values to
Javascript


Writing Javascript with Velocity can be a little tricky, but just
remember that you use Velocity to set the values for constant fields
acted on by the Javascript function.

Do not write a Javascript function that tries to manipulate a Velocity
context object at runtime, because the Velocity context is not
available once the request leaves the server.  Javascript is run by
the client browser, which has no access to Velocity.

Barbara Baughman
X2157

On Thu, 23 Jun 2005, Veerappan Sridhar wrote:

> Hi,
>  Pls help how i can get the database values in javascript.
> I got list of values retrieved from backend and stored in arraylist
> like
> $alroles,
>  so now i can pass these values to javascript and access.
> Scenario:
> i have n number of text box,the text box(i) contains some values
that
> values should be checked with the backend values for that i need a
> function to pass and compare in javascript.
>
> So pls help me
>
> Thanks
> Sridhar
>
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org

> For additional commands, e-mail:
velocity-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org







---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org






---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org