JavaScript variable

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

JavaScript variable

detlef.hebbel
Hi.

I am calling a JS Œvar¹ from an external file and want to create a Lasso
Œvar¹ like this:

[var: 'company'='<script
type="text/javascript">document.write(Company)</script>']
[$company]

Then, I put the Lasso Œvar¹ into a Œhidden¹ field:
<input type="hidden" name="Company" value="[$Company]" />

It does not work...

The result is:

My Company Name INC document.write(Company)" />

Can somebody point me into the right direction please? Or is there a better
way to get a JS Œvar¹ from an external file into Œhidden¹ field?

Thanks
Detlef



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: JavaScript variable

Bil Corry-3
Detlef Hebbel wrote on 11/1/2007 2:58 PM:
> [var: 'company'='<script
> type="text/javascript">document.write(Company)</script>']
> [$company]

This won't work because the JavaScript won't execute until the browser gets it, but by then, Lasso is no longer processing the page.  You have to use only JavaScript for your solution.  If you're using jQuery, it'd look like this (assuming "Company" is a JS var that holds your company value):

<script language="JavaScript" type="text/javascript">
    $(function(){
        $("#Company").val(Company);
    });
</script>

<input id="Company" type="hidden" name="Company" value="" />



- Bil


--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/

Reply | Threaded
Open this post in threaded view
|

Re: JavaScript variable

detlef.hebbel
Thanks Bil.

I'll have a look into jQuery to solve this one.

Cheers
Detlef


on 2/11/07 9:46 AM, Bil Corry at [hidden email] wrote:

> Detlef Hebbel wrote on 11/1/2007 2:58 PM:
>> [var: 'company'='<script
>> type="text/javascript">document.write(Company)</script>']
>> [$company]
>
> This won't work because the JavaScript won't execute until the browser gets
> it, but by then, Lasso is no longer processing the page.  You have to use only
> JavaScript for your solution.  If you're using jQuery, it'd look like this
> (assuming "Company" is a JS var that holds your company value):
>
> <script language="JavaScript" type="text/javascript">
>     $(function(){
>         $("#Company").val(Company);
>     });
> </script>
>
> <input id="Company" type="hidden" name="Company" value="" />
>
>
>
> - Bil
>



--
This list is a free service of LassoSoft: http://www.LassoSoft.com/
Search the list archives: http://www.ListSearch.com/Lasso/Browse/
Manage your subscription: http://www.ListSearch.com/Lasso/