Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-28-2010, 01:50 AM   PM User | #1
extremed
New Coder

 
Join Date: Jun 2010
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
extremed is an unknown quantity at this point
Access Smarty value with javascript

Hi

someone please let me know the way to access a smarty value with javascript?

my smarty value is = {$value.url}

i want to access it like

Code:
<script type="text/javascript">
function load()
{
	document.location = '{$value.url}';	
}
</script>

i tried with wrapping code with {literal} {/literal} but it isnt working. can some one correct this please

sorry for bad english

Thanks
extremed is offline   Reply With Quote
Old 06-28-2010, 07:09 AM   PM User | #2
Dormilich
Senior Coder

 
Dormilich's Avatar
 
Join Date: Jan 2010
Location: Behind the Wall
Posts: 2,881
Thanks: 9
Thanked 291 Times in 287 Posts
Dormilich is on a distinguished road
you can’t. (unless we’re talking not about Smarty, the PHP templating engine)

PHP finished working before JavaScript starts up. The only way JS can interact with PHP is through a HTTP Request. however, you can use PHP (and Smarty) to print out JS code.
__________________
please post your code wrapped in [CODE] [/CODE] tags
Dormilich is offline   Reply With Quote
Old 06-28-2010, 08:42 AM   PM User | #3
extremed
New Coder

 
Join Date: Jun 2010
Posts: 59
Thanks: 0
Thanked 0 Times in 0 Posts
extremed is an unknown quantity at this point
I got it working by

{literal}
<script type="text/javascript">
function load()
{
document.location = '{/literal}{$value.url}{literal}';
}
</script>
{/literal}
extremed is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:24 PM.


Advertisement
Log in to turn off these ads.