There was a recent discussion about adding numeric variables together into a single variable output. Does anyone have any ideas how to string the values of several input TextEntry boxes into one final variable?
Here's another one for you master Phil.... Suppose I wanted to now stack these entries. Rather than string them together, what's the widget code for a hard return?
Looks like this (well... if the forum didn't eat my tags):
//this grabs the player object from the parent (launching window)
var player=window.opener.GetPlayer();
//now we pull a field value. You can pull as many as you like. That replace jumble lets you bring over text fields with multiple lines.
var learnerName=player.GetVar("learner").replace(/(\r\n|\r|\n)/g, '<br />');
document.write("<div class='result'>"+learnerName+", you have passed <b>The Grueler</b>!<br/><br/><em>For that feat, you deserve a break. Take 30 seconds. Then get back to work!</em></div>");
The ".replace(/(\r\n|\r|\n)/g, 'break tag' bit is what takes care of breaking up those lines.
Thanks for the explaination Steve, I fluked a line return.
The more javascript I get to use the more I understand it.
Oh and thanks for the codeacademy link really great site
Hi Guys,
Can you please explain further how to do a concatenation? I have numeric keypad from 1 to 9 and 0. I want to animate when a user successfully click the so called password. Let say they enter 1234, then I will proceed with the show layer to animate. My big question is, how to get the input together? How to concatenate the user's input? How to join two strings together?
Not sure you need to concatenate here, if you are not using decimals just multiply by ten and add the number
e.g
First press = 1 (triggers multiply by ten and add 1) visible = 1
second press = 2 (triggers multiply by ten and add 2) visible = 12
third press = 3 (triggers multiply by ten and add 3) visible = 123
forth press = 4(triggers multiply by ten and add 4) visible = 1234
Hi Phil,
Thanks a lot for your reply. Sorry for my lack of understanding, but I don't seem to get the logic you posted. for example,
on second press = 2 (2 x 20 +2) = should be equal to 22. Following the logic you gave.
And also, aside from 1-9 and zero keys, there are two more, there is a " * " and " c ". C is to clear the input, and * is used in the programming. I am trying to figure out, how I can get the users input, and compare if they have the right password. Let say, the password is 112335. Thanks a lot.
Thank you for your reply again. It is greatly appreciated. I completely understand your reply above. But I don't seem to get it on the succeeding line, sorry.
1 -> 1 x 10 =10+2 = 12
2.--> 2x10 = 20+3 = 23
3--> 3 x 10 = 30+4 = 34
4. --> 4x10 = 40.
Can you please check where I had it wrong? Thank you.
Also, does the algorithm you are suggesting works if the password is: 112335
I think you are still missing what I am trying to say (but it is likely the way I am saying it), you need a variable for this sake lets call it display
Each button 1 -9 has two triggers one multiplies display by 10 the other adds the respective value from 1-9 to the value of display
My example on each button press
1-> display value = 0 x 10 +1 = 1
2-.>display value = 1 x 10+2 = 12
3 ->display value = 12 X10+3 = 123
4 ->display value = 123 x 10 +4 = 1234
Will work for every example
rTrigger order is important must be x10 then +x where x is the value of the button.
I am trying to add the contents of multiple text variables into a blank text variable. The example .story file on this page is blank. Can you help me out with the required javascript to do this?
Which .story file are you referring to? This thread dates back a bit - so I wasn't certain which one you were looking at to try and open it to see if I could see the information Also, the javascript element won't be visible on the slide itself, you'll have to look at the triggers .
Hopefully someone else with more Javascript expertise in the community will also weigh in and share any thoughts here as well.
I'm trying to automate a grocery bill based on the items selected by the user. I think this would work for what I want to do, however I can't access the file. Was it removed? I tried downloading but it only displays a scrambled html page.
You may need to change the file type/location when you conduct the download and make sure it's saving as a .story file. Also if the download isn't happening as you'd expect I'd suggest trying it in another browser as well.
28 Replies
It's called concatenation. Several of us have submitted feature requests in the past. Please feel free to send one in, too.
You could do this in a javascript trigger, would be easy just use the + operator
see the attached file
+1 for concatenation.
As a matter of interest, where do we find the feature / bug submission form now?
Best regards,
Mark
Hey, Mark!
Not sure for bugs, but I think we now submit a case? http://www.articulate.com/support/contact/submit.php
That's what I've done so far.
For feature requests: http://www.articulate.com/support/contact/submit.php?form=feature
Thanks fellas! And thanks Phil for the JS example. That works great, but one question: How to add a "space" between the two variables?
I added quotes to: var c = a+""+b;
Didn't seem to work. Any ideas? Otherwise the two text boxes merge into one string.
var c = a+" "+b;
should work, see attached
You didnt say you wanted a space
Pesky spaces! Thanks for spotting my error.
Here's another one for you master Phil.... Suppose I wanted to now stack these entries. Rather than string them together, what's the widget code for a hard return?
Instead of this:
Text1, Text2, Text3, Text4, ...
This:
Text1
Text2
Text3
Text4
"\n" seems to work
Cool. Lemme try that. See how this works? Storyline is an indirect addiction to learning a new language.
Guess that makes it a gateway drug?
Hey, Kevin -
You'll need to replace the carriage returns with a break. Take a look at the code in the certificate page here:
http://community.articulate.com/forums/t/12471.aspx
Looks like this (well... if the forum didn't eat my tags):
//this grabs the player object from the parent (launching window)
var player=window.opener.GetPlayer();
//now we pull a field value. You can pull as many as you like. That replace jumble lets you bring over text fields with multiple lines.
var learnerName=player.GetVar("learner").replace(/(\r\n|\r|\n)/g, '<br />');
document.write("<div class='result'>"+learnerName+", you have passed <b>The Grueler</b>!<br/><br/><em>For that feat, you deserve a break. Take 30 seconds. Then get back to work!</em></div>");
The ".replace(/(\r\n|\r|\n)/g, 'break tag' bit is what takes care of breaking up those lines.
Thanks for the explaination Steve, I fluked a line return.
The more javascript I get to use the more I understand it.
Oh and thanks for the codeacademy link really great site
Hi Guys,
Can you please explain further how to do a concatenation? I have numeric keypad from 1 to 9 and 0. I want to animate when a user successfully click the so called password. Let say they enter 1234, then I will proceed with the show layer to animate. My big question is, how to get the input together? How to concatenate the user's input? How to join two strings together?
Thank you.
Not sure you need to concatenate here, if you are not using decimals just multiply by ten and add the number
e.g
First press = 1 (triggers multiply by ten and add 1) visible = 1
second press = 2 (triggers multiply by ten and add 2) visible = 12
third press = 3 (triggers multiply by ten and add 3) visible = 123
forth press = 4(triggers multiply by ten and add 4) visible = 1234
Hi Phil,
Thanks a lot for your reply. Sorry for my lack of understanding, but I don't seem to get the logic you posted. for example,
on second press = 2 (2 x 20 +2) = should be equal to 22. Following the logic you gave.
And also, aside from 1-9 and zero keys, there are two more, there is a " * " and " c ". C is to clear the input, and * is used in the programming. I am trying to figure out, how I can get the users input, and compare if they have the right password. Let say, the password is 112335. Thanks a lot.
no you multiply by ten and add the number so if you input 1 first the 2, you would multiply 1 by ten then add 2 which is 12
Not sure about what the * does but clear would simply reset the variable
Hi Phil,
Thank you for your reply again. It is greatly appreciated. I completely understand your reply above. But I don't seem to get it on the succeeding line, sorry.
1 -> 1 x 10 =10+2 = 12
2.--> 2x10 = 20+3 = 23
3--> 3 x 10 = 30+4 = 34
4. --> 4x10 = 40.
Can you please check where I had it wrong? Thank you.
Also, does the algorithm you are suggesting works if the password is: 112335
Thank you phil
I think you are still missing what I am trying to say (but it is likely the way I am saying it), you need a variable for this sake lets call it display
Each button 1 -9 has two triggers one multiplies display by 10 the other adds the respective value from 1-9 to the value of display
My example on each button press
1-> display value = 0 x 10 +1 = 1
2-.>display value = 1 x 10+2 = 12
3 ->display value = 12 X10+3 = 123
4 ->display value = 123 x 10 +4 = 1234
Will work for every example
rTrigger order is important must be x10 then +x where x is the value of the button.
Michaels example here may help http://community.articulate.com/forums/p/50435/271153.aspx#271153
I am trying to add the contents of multiple text variables into a blank text variable. The example .story file on this page is blank. Can you help me out with the required javascript to do this?
Hi Michael,
Which .story file are you referring to? This thread dates back a bit - so I wasn't certain which one you were looking at to try and open it to see if I could see the information Also, the javascript element won't be visible on the slide itself, you'll have to look at the triggers .
Hopefully someone else with more Javascript expertise in the community will also weigh in and share any thoughts here as well.
I'm trying to automate a grocery bill based on the items selected by the user. I think this would work for what I want to do, however I can't access the file. Was it removed? I tried downloading but it only displays a scrambled html page.
Any help appreciated.
Hi Candice,
You may need to change the file type/location when you conduct the download and make sure it's saving as a .story file. Also if the download isn't happening as you'd expect I'd suggest trying it in another browser as well.
This discussion is closed. You can start a new discussion or contact Articulate Support.