gardin wrote: ↑Thu Jan 14, 2021 3:55 am
gardin wrote: ↑Thu Jan 14, 2021 2:19 am
Code: Select all
var html = "<div class='dbm' class='dbm' style='padding:10px;background-color:gray;color:white;top:80px;position:absolute;right:500px;border:1px solid black;z-index:1000;'><table width='100%' class='table'><tr><td>Type : </td><td><input name='tipe' checked value='1' type='radio'> Image <input name='tipe' value='2' type='radio'> File</td></tr><tr><td>Text1 : </td><td><input style='color:black !important;' value='2' type='text' class='c' /></tr><tr><td>Text2 : </td><td><input value='0' style='color:black !important;' type='text' class='d' /></tr><tr><td>Text3 : </td><td><input value='0' style='color:black !important;' type='text' class='e' /></tr><tr><td>Textarea : </td><td><textarea style='color:black !important;' class='r'></textarea></td></tr><tr><td colspan='2' align='center'><input class='btn btn-primary b1' style='color:white;background-color:orange !important' type='submit' value='Mulai' onclick=\"javascript:(function(){ var a=document.getElementsByClassName('c');a=a[0]; alert(a.value); }) ()\" /><input class='b2 btn btn-primary' onclick=\"javascript:(function(){var dbm=window.content.document.getElementsByClassName('dbm');dbm[0].innerHTML='' ; }) ()\" style='background-color:blue;color:white; !important' type='submit' value='Close' /></td></tr></table></div>";
var document=window.document;
//window.content.document.getElementsByClassName('dbm')[0].innerHTML = "";
document.body.innerHTML += (html);
alert(a);
I posted these code already? Or should i put without <code> tag?
[...]
Oh...!, yep indeed, that's the one I meant, I had missed it indeed, "focusing" a bit on the 2 Screenshots that had not been uploaded to the Forum like I had asked, and you had 2 Screenshots, so I expected 2 Scripts...
OK, I only keep your formatted Script in my Quote, but keep indeed the non-formatted "Version" in your own Post, the "var html" Declaration is "so long", that it is indeed not very easy to read from the one-Line in the formatted Script, and it's easier to read from your Post...
So OK, "now" I understand where your "a" is coming from in the (final) "alert(a)" in your Script.
So this is the Script you were saying:
No luck in getting the variable to be used "outside". It keeps saying variable is not defined, or illegal syntax (see i am trying to alert "a" variable outside)
... And the Runtime Error (that I have to retype) from your Screenshot is:
Code: Select all
ReferenceError: a is not defined, line 7 (Error code: -991)
Then yep..., I'm not "too surprised", the "a" is only declared and known within the "Scope" of the "html" Var, and the JS Runtime Engine doesn't know anything (anymore) at the next Line in your Script...
So what you are missing is a Mechanism to pass the Content of that "a" Var to outside of the "html" Line for the rest of the Script to be able to access it and reuse it.
=> Still in the "html" Statement, see if you can pass it to the OS Clipboard in pure JS, or you would need to append some "fake" (invisible) 'DIV' to your Popup to re-extract at some next Line either using the 'EXTRACT' Mechanism in 'iim' or in pure JS, while the Popup is still "visible".
But I reckon the Popup will be Modal, so this won't work as the Popup will have already been dismissed when your Script will try to execute the next Line after the "html" Line, ah-ah...!
Then instead of appending that 'DIV' to the Popup, you will need to inject it directly in the "main" HTML of the "Parent" Page, (still from your "html" Line), where iMacros will then be able to re-extract it.
But this is "a bit" cumbersome, ah-ah...! But your Popup Declaration is already "a bit" cumbersome, ah-ah...! Now I understand what you were meaning with "rich Content", ah-ah...!
I still find like I had told you in your Original Thread on SOF that using the iMacros 'PROMPT' Command would be much easier, I would think..., as you probably don't really need all the "fancy" Formatting in your Popup...
I have an Enhancement Request btw in
the following Thread, => Item "5" about 'PROMPT' + 'ONPROMPT' to extend indeed a bit the whole Functionality of the 'PROMPT' Command. Feel "free" to support that EnhReq if you want, ah-ah...!
But we use the same Technique to pass a Var in pure '.iim' from an "URL GOTO=javascript" Line/Statement to the rest of the Script. Let me find a Thread where this has been demonstrated... Yep, in
this Thread for example, from the Post I link to and beyond, other Advanced User @thecoder2012 is much more knowledgeable than me in pure JS, then in
this Thread also I think, and there should be another Thread on the Forum, from other Advanced User @iimfun, but I can seem to be able to locate it easily...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...