Highlighted

TextInput not working how I expect - HTML5

New Here ,
Apr 24, 2020

Copy link to clipboard

Copied

Hi All,

I am trying to allow users to input a name that will then update Dynamic Text. Before that, however, I simply want to print the user-typed into console, but I can't seem to get this to work. 

 

My code. This is placed on the second frame of a movie clip that is activated with a button on the main scene: 

 

this.stop();
var txt_pet1 = document.getElementById("PET1_NAME_TEXT1");

this.NAME_APPLY_BUTTON.on("click", onApply.bind(this));

function onApply(e) {
	var pet1_name = document.getElementById("PET1_NAME_TEXT1").value; 
	console.log(pet1_name);
}

 

 When the click the "Apply" button, I expect the inputted text to show up but instead I get nothing. I also have an error in console saying "[DOM] Found 2 elements with non-unique id #PET1_NAME_TEXT1" but I don't think this is defined anywhere else.

 

Any help is appreciated!

 

Melanie

 

Screen Shot 2020-04-24 at 10.57.07.png

 

Views

69

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

TextInput not working how I expect - HTML5

New Here ,
Apr 24, 2020

Copy link to clipboard

Copied

Hi All,

I am trying to allow users to input a name that will then update Dynamic Text. Before that, however, I simply want to print the user-typed into console, but I can't seem to get this to work. 

 

My code. This is placed on the second frame of a movie clip that is activated with a button on the main scene: 

 

this.stop();
var txt_pet1 = document.getElementById("PET1_NAME_TEXT1");

this.NAME_APPLY_BUTTON.on("click", onApply.bind(this));

function onApply(e) {
	var pet1_name = document.getElementById("PET1_NAME_TEXT1").value; 
	console.log(pet1_name);
}

 

 When the click the "Apply" button, I expect the inputted text to show up but instead I get nothing. I also have an error in console saying "[DOM] Found 2 elements with non-unique id #PET1_NAME_TEXT1" but I don't think this is defined anywhere else.

 

Any help is appreciated!

 

Melanie

 

Screen Shot 2020-04-24 at 10.57.07.png

 

Views

70

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 24, 2020 0

Have something to add?

Join the conversation