Send Value HTML tag to Text event

  • 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.

  • 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.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)