Page 1 of 1

Dynamic tinymce id

Posted: Wed Dec 07, 2011 2:56 pm
by babusar
im having problem using javascript dom defined on forum to enter text into tinymce textarea . my text area id is dynamic so its not possible to pull content into it. here is javascript dom im using with complete macro below
URL GOTO=javascript:void(tinyMCE.editors[dynamic id].setContent('{{!COL2}}'));

Code: Select all

VERSION BUILD=7300701 RECORDER=FX
TAB T=1
URL GOTO=javascript:void(tinyMCE.editors[dynamic id].setContent('{{!COL2}}'));
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:editor ATTR=ID:u* CONTENT={{!COL3}}



Re: Dynamic tinymce id

Posted: Thu Dec 08, 2011 2:53 pm
by babusar
:( no response ? will appreciate if anyone would like to help

Re: Dynamic tinymce id

Posted: Thu Dec 08, 2011 6:17 pm
by willjohnathan
I am kind of new to IMACROS, but have you tried something like this

Code: Select all

'get textarea html tag containing dynamic id
TAG POS=1 TYPE=TEXTAREA ATTR=ID:* EXTRACT=HTM
'use javascript regex to find id and set to var1
SET !VAR1 EVAL("var x='{{!EXTRACT}}'; var y = x.split(' '); var j = x.length; var i = 0; var s = 'id='; for(i;i<j;i++){if(y[i].indexOf(s) != -1){var myId = y[i].replace('id=', ''); myId = myId.replace(/\"/g, \"\"); i=j; }} myId;")
'var1 should equal id
URL GOTO=javascript:void(tinyMCE.editors['{{!VAR1}}'].setContent('!COL2}}'));
you might need to tweak it a little bit especially if the id is followed by the closing tag, but I think this concept should work for ie9 at least.

Re: Dynamic tinymce id

Posted: Thu Dec 08, 2011 7:00 pm
by willjohnathan
Also, if the textarea already has data you might want to put this line of code before the other code I posted because it seems IMACROS has difficulty with certain types of data in these types of textareas

Code: Select all

TAG POS=1 TYPE=TEXTAREA ATTR=ID:* CONTENT=
Of coarse if this isn't the only textarea on the page, then you might need to reference it by a class attribute or different position number or something.

Re: Dynamic tinymce id

Posted: Sat Dec 10, 2011 10:58 am
by babusar
Thnx it worked ! :)

Re: Dynamic tinymce id

Posted: Sat Dec 10, 2011 12:13 pm
by topbgt
thanks willjohnathan :D
I found what I was looking here
regards