Support Forums

Getting extrafield values in JavaScript

This is a discussion on Getting extrafield values in JavaScript within the Templates, HTML, CSS, and Design Help forums, part of the General category; Hi everyone, I was wondering if it's possible to automatically get the value of an extrafield variable using JavaScript. A ...


Go Back   68 Classifieds Forums > General > Templates, HTML, CSS, and Design Help

Reply
 
Thread Tools Display Modes
Old 01-11-2010, 11:26 AM   #1
Customer
 
Join Date: Dec 2009
Posts: 6
Rep Power: 0
modworldwide is on a distinguished road
Default Getting extrafield values in JavaScript

Hi everyone,

I was wondering if it's possible to automatically get the value of an extrafield variable using JavaScript.

A little info that might be relevant: I'm trying to add a Google Maps feature to the viewlistings.tpl page that will display a specified stored address as soon as the page loads. The script itself is functional, but it can only receive the value through clicking an html button on the page - I am hoping this step isn't necessary... Any help would be really appreciated. Thanks!
modworldwide is offline   Reply With Quote
Old 01-11-2010, 02:36 PM   #2
All Hands On Deck
 
 
Join Date: Mar 2008
Posts: 3,342
Rep Power: 84
seymourjames is a jewel in the rough
Default

Welcome to the forum.

In general you get the value of an extrafield using a standard plugin within the folder of the same name. There are quite a few examples of using extrafields and manipulating them on the forum. I am not aware of a specifc javascript function that returns extrafields.
__________________
"The fool doth think he is wise, but the wise man knows himself to be a fool.".

TemplateCodes.com for 68C, Version 4 Templates & Modules
Get the Best U.S Hosting, Best U.K Hosting
seymourjames is offline   Reply With Quote
Old 01-11-2010, 03:48 PM   #3
Customer
 
Join Date: Dec 2009
Posts: 6
Rep Power: 0
modworldwide is on a distinguished road
Default

Thanks for the reply. I've been manipulating the extrafield information on the templates themselves, but having trouble with JavaScript since it handles variables differently... On a normal website, it can return PHP variable data, and since these are technically PHP files, it seems like this should be able to be done...?
modworldwide is offline   Reply With Quote
Old 01-11-2010, 03:55 PM   #4
Staff
 
Join Date: Mar 2006
Location: New Jersey
Posts: 2,149
Rep Power: 68
John Snyder is a jewel in the rough
Default

Just open the template file and use smarty to create the javascript vars:

HTML Code:
<script language="javascript" type="text/javascript">
<!--//
    var address = "{$owneraddress}";
//-->
</script>
Also, I know lHotch has a very complete google maps module, which might save you time, or provide some advanced features. It can found be here: techconnx.net - Google Maps Module
__________________
John
68C Staff

68C Downloads | Report a Bug | Knowledge Base
If you have a current support subscription, you can Submit a Support Ticket
John Snyder is offline   Reply With Quote
Old 01-11-2010, 04:36 PM   #5
Customer
 
Join Date: Dec 2009
Posts: 6
Rep Power: 0
modworldwide is on a distinguished road
Default

Hmm, I tried setting it that way, and using a basic "alert(address)" to test, but this returned as being literally {$owneraddress}

Thank you for the module recommendation, that's a little more involved than what this company is going for. The map is functioning the way they want, except for the variable issue mentioned above, which I'm guessing has an annoyingly simple solution (like the method you suggested)
modworldwide is offline   Reply With Quote
Old 01-11-2010, 04:59 PM   #6
68 Classifieds Staff
 
Eric Barnes's Avatar
 
Join Date: Mar 2006
Location: Belmont, NC
Posts: 5,489
Rep Power: 135
Eric Barnes is just really nice Eric Barnes is just really nice
Default

Try:
Code:
{/literal}{$owneraddress}{literal}
__________________
Eric Barnes
68 Classifieds Developer
Customer Area | Issue Tracker | Documentation | 68C Mods | 68 @ Twitter | My Modules
Eric Barnes is offline   Reply With Quote
Old 01-11-2010, 05:21 PM   #7
Customer
 
Join Date: Dec 2009
Posts: 6
Rep Power: 0
modworldwide is on a distinguished road
Default

Great! That worked perfectly, thanks much.
modworldwide is offline   Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display extrafield as one word command. damiun Customizations 5 12-01-2009 10:16 AM
Extrafield Sort Order wendel18 Technical Support 1 08-08-2009 09:05 PM
Caegory values ryanreed71 Technical Support 7 02-13-2009 09:27 PM


All times are GMT -4. The time now is 01:10 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2011, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0