Who is online?
In total there is 1 user online :: 0 Registered, 0 Hidden and 1 Guest

None

[ View the whole list ]


Most users ever online was 246 on Tue 31 Jan - 2:47
Statistics
We have 150 registered users
The newest registered user is Luxic

Our users have posted a total of 2050 messages in 200 subjects
Latest topics
» A small share
by Flora Today at 21:03

» Edit the 404 page on Forumotion
by LGforum Today at 15:29

» How to Change The Homepage?
by LGforum Today at 15:28

» Counter for my notices box
by Niko Today at 15:03

» 21. Show Recent Topics Preview In Accordion
by ReBoRN Yesterday at 19:08

17. Variable in HTML Pages and Templates

Page 2 of 2 Previous  1, 2

View previous topic View next topic Go down

Re: 17. Variable in HTML Pages and Templates

Post by ion-cube on Fri 20 Jan - 3:28

@ http://jsfiddle.net/defencedog/cu5VJ/

Provided that we can use this also:

$('.' + x[i].id).text(x[i].innerHTML);

why can't we use

$('.' + x[i].id).innerHTML(x[i].innerHTML);

ion-cube

Status Status: Testing
Posts: 121
Join date: 2011-10-19
Age: 23
Location: Pakistan

View user profile

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by pidot101 on Fri 20 Jan - 4:07

how about a user avatar??

what id should i use?

pidot101

Status Status: . . .
Posts: 58
Join date: 2011-12-09
Age: 16

View user profile

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by LGforum on Fri 20 Jan - 10:28

ion-cube wrote:@ http://jsfiddle.net/defencedog/cu5VJ/

Provided that we can use this also:

$('.' + x[i].id).text(x[i].innerHTML);

why can't we use

$('.' + x[i].id).innerHTML(x[i].innerHTML);


Because 'innerHTML' is native javascript method to be used on elements. In that second line of yours it would be using it on a jQuery function not an element.

LGforum


Forum Version: Phpbb3
Posts: 729
Join date: 2011-10-05
Location: UK

View user profile http://www.avacweb.com

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by LGforum on Fri 20 Jan - 11:05

A sort of follow up mini tutorial here: http://www.avacweb.com/t129-user-avatar-variable

LGforum


Forum Version: Phpbb3
Posts: 729
Join date: 2011-10-05
Location: UK

View user profile http://www.avacweb.com

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by midoweb96 on Tue 7 Feb - 8:03

very nice code .
i trying code sooon
thanks.

midoweb96

Posts: 3
Join date: 2012-02-06

View user profile

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by ion-cube on Sun 12 Feb - 8:28

I need another clarification, in this line
$('.'+x[i].id).html(x[i].innerHTML);

what is .id ?

ion-cube

Status Status: Testing
Posts: 121
Join date: 2011-10-19
Age: 23
Location: Pakistan

View user profile

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by LGforum on Sun 12 Feb - 18:01

Thats the clever bit of this script.
It loops through the elements holding the variables, and it gets that elements ID.
So 'x[i].id' is the ID of the element, so for instance 'USERNAME'
the '.'+x[i].id would = '.USERNAME' which when put into a jQuery selector, wil search the element with className of USERNAME, and inserts the same HTML as the variable Smile

LGforum


Forum Version: Phpbb3
Posts: 729
Join date: 2011-10-05
Location: UK

View user profile http://www.avacweb.com

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by ion-cube on Sun 12 Feb - 18:25

thank you sir...BUT I knew why it was there the question was WHAT it was I can't find any documentation on .id ??

ion-cube

Status Status: Testing
Posts: 121
Join date: 2011-10-19
Age: 23
Location: Pakistan

View user profile

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by LGforum on Sun 12 Feb - 18:27

Oh okay. Yup most attributess can be accessed just like that.
Code:

elem.id
elem.href
elem.target
elem.className
etc...

LGforum


Forum Version: Phpbb3
Posts: 729
Join date: 2011-10-05
Location: UK

View user profile http://www.avacweb.com

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by ion-cube on Sun 12 Feb - 18:47

is it jquery or js syntax

ion-cube

Status Status: Testing
Posts: 121
Join date: 2011-10-19
Age: 23
Location: Pakistan

View user profile

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by LGforum on Sun 12 Feb - 20:21

Native JS.

LGforum


Forum Version: Phpbb3
Posts: 729
Join date: 2011-10-05
Location: UK

View user profile http://www.avacweb.com

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by razvan on Fri 24 Feb - 12:45

is this working with all the variables from the templates?

razvan

Posts: 17
Join date: 2011-11-11

View user profile

Back to top Go down

Re: 17. Variable in HTML Pages and Templates

Post by LGforum on Fri 24 Feb - 19:34

Its with all the ones FM provide for you to use.
Not the ones IN templates like {GENERATED_NAV_BAR} and stuff.

LGforum


Forum Version: Phpbb3
Posts: 729
Join date: 2011-10-05
Location: UK

View user profile http://www.avacweb.com

Back to top Go down

Page 2 of 2 Previous  1, 2

View previous topic View next topic Back to top


Permissions in this forum:
You cannot reply to topics in this forum