inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jan 17, 2013 11:32:43 GMT -8
I am rewriting a plugin, and I have an HTML box set to it's contents being javascript. I'm having the user specify an array using ["content","content2","content3"], ["content","content2","content3"], ["content","content2","content3"], ["content","content2","content3"]
But it's not properly doing it. I inputed that exact above directly into the JS and got it right. But using the variable for the contents of the JS box in the UI it doesn't work.
Any help?
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Jan 17, 2013 12:06:23 GMT -8
I think you'll have to give bit more detail on how you're reading the array and then adding it to 'a table?'
This bit I don't understand- 'and I have an HTML box set to it's contents being javascript'
Maybe I'm just been slow today and someone else will jump in.
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jan 17, 2013 13:45:24 GMT -8
This bit I don't understand- 'and I have an HTML box set to it's contents being javascript' In a plugin, you can add a code box(my mistake for calling it HTML box) and you set it that it reads a JavaScript, HTML, or CSS, and I have it set to JavaScript. var tArray = [ ["input","GT","Hello"], ["input","GT","Hello"], ["input","GT","Hello"], ["input","GT","Hello"] ]
for(i=0;i<tArray.length;i++) { var tAry = tArray[i]; if(tAry[0] == 'input') { //code to run; } else if(tAry[0] == 'textarea') { //code to run } else if(tAry[0] == 'select') { //code to run } } Whenever I use the above directly in the code, it works fine, but when I use a variable, it doesn't. In the JS box in the UI, I have the array set. I have even tried alerting the variable to see if I maybe didn't loop through correct for that one variable, but it gave me what I had input in the JS Box in the plugin UI. Nah I'm sure your fine.
|
|
#00AF33
Bark Different.
102833
0
1
Feb 12, 2023 16:57:46 GMT -8
RedBassett
I'm a Marxist/Lennonist of the Groucho/John variety.
15,405
April 2007
applecomputer
RedBassett's Mini-Profile
|
Post by RedBassett on Jan 17, 2013 14:18:39 GMT -8
Are you using a browser to check breakpoints or for code errors?
What happens if you add this line before the for loop (obviously change the variable name as appropriate)?
alert(tArray);
Or if you use your browser's console, this will give you more info:
console.log(tArray);
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jan 17, 2013 14:26:19 GMT -8
using alert I get 'input,GT,Hello,input,GT,Hello,input,GT,Hello,input,GT,Hello'
and using console.log I get ReferenceError: tArray is not defined.
|
|
#00AF33
Bark Different.
102833
0
1
Feb 12, 2023 16:57:46 GMT -8
RedBassett
I'm a Marxist/Lennonist of the Groucho/John variety.
15,405
April 2007
applecomputer
RedBassett's Mini-Profile
|
Post by RedBassett on Jan 17, 2013 14:33:35 GMT -8
Did you substitute the correct variable name for "tArray" in the console line? Or is tArray the correct name?
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jan 17, 2013 15:43:22 GMT -8
Just wanted to clarify sorry. But adding the array in directly gives me what I said before.
Using the content I get from the JS box in the plugin settings.
alert gives me '["input","GT","What's your GT?"], ["input","hey","What's your GT?"]'
And I get the same message with the console.log method. Thats its undefined. And yes, tArray is the name.
|
|
inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Jan 18, 2013 8:25:17 GMT -8
I may be way off the mark with this Wouldn't it be easier for the user to have inputs in an Auto-form? No chance of clamps, " or , going missing. You could then loop through the auto-form variable and if you wanted you could make the array from this in the code. var tArray = [ ["input","GT","Hello"], ["input","GT","Hello"], ["input","GT","Hello"], ["input","GT","Hello"] ]
for(i=0;i<tArray.length;i++) {
if(tArray[i][0] == 'input') { //code to run; } else if(tArray[i][0] == 'textarea') { //code to run } else if(tArray[i][0] == 'select') { //code to run } }
[/code]
|
|
inherit
170346
0
Mar 1, 2016 12:53:37 GMT -8
Shorty
Yeah, I'm that cool. Lol! No I'm not.
3,018
August 2011
shortyverrett94
|
Post by Shorty on Jan 18, 2013 8:30:22 GMT -8
That's how it currently is. But I'm trying to make it so that so that you can have different boards with different templates. And for that you would need an autoform with an autoform.
|
|