Send Value HTML tag to Text event

Discussion and feedback on Construct 2

Post » Tue Jul 11, 2017 6:39 am

Hello good day;
I am trying to send the value of a html tag of a game that I made and it captures in a frame with construct 2. With which it gives me continuously a numeric value that I can capture without problems with js, but that the construct text event does not Catch, it always shows me Nan or 0. Is there any way to capture that value? I did a thousand tests with Ajax, PHP $ SESSION.
Last edited by xyt1 on Tue Jul 11, 2017 9:35 am, edited 2 times in total.
B
3
Posts: 4
Reputation: 183

Post » Tue Jul 11, 2017 9:08 am

The C2 game is in an iFrame, right ?
Then you need to call a function from your game that will send the information to the function set in the hosting/embedding HTML page.

The function is set in the HTML page, you call the same name using the Function plugin and passing your value as parameter.
The function in the HTML page has to be proper JS in the <script> tag.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
292
S
115
G
96
Posts: 7,295
Reputation: 70,795

Post » Tue Jul 11, 2017 9:24 am

Yes, an iFrame. The problem is that my js inside the page that I call inside the frame works because I skip the alert () with the value of the HTML tag. But I can not find the way to capture that value from C2.

Inside the HTML alert ():
Var variablejs = document.getElementById ("NoteValorHz"). InnerHTML;
Alert (variablejs)

I want the value of that label to be captured by C2 just as I can do without problems with js.
B
3
Posts: 4
Reputation: 183

Post » Tue Jul 11, 2017 10:01 am

The function needs to be in the hosting page, not the embedded page.
And don't use the alert, make your own function which the parameter is your "captured" value.

And within C2 you have to make the call towards this function. When to make the call depends on your application.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
292
S
115
G
96
Posts: 7,295
Reputation: 70,795

Post » Tue Jul 11, 2017 10:13 am

From what you say, I understand that I have to add to the HTML that generates C2 the js function that captures the value. So perfect there but as I say to C2 with the event text for example that takes that variable of js that captured with the method of the site the value of frame.
B
3
Posts: 4
Reputation: 183

Post » Tue Jul 11, 2017 11:22 am

Load a problem in place to see it. The value that at first is 440 is the value that has to be loaded in the text tag of C2, but it does not.
B
3
Posts: 4
Reputation: 183


Return to Construct 2 General

Who is online

Users browsing this forum: JesusJ, troublesum, Yahoo [Bot] and 11 guests