• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

how to get focus on a button in ANCC HTML5

LEGEND ,
Dec 04, 2019 Dec 04, 2019

Copy link to clipboard

Copied

I have 6 input texts and a submit button set on visible =  false.

When all 6 input texts are filled in the submit button has visible  =  true. This works fine but I want the button then to get the focus. I can get focus on the input text but I am not sure how to do it with the submit button.

function checkIfDone() {	
	if (result1.length != 0 && result2.length != 0 && result3.length != 0 && result4.length != 0 && result5.length != 0 && result6.length != 0) {
		root.submitBtn3.visible = true;
	} else {
		root.submitBtn3.visible = false;
	}
}

 

Each input has this code:

function A_change(evt) {
	result1 = [];
	result1.push(evt.target.value);
        // move to next imput field
	$("#B").select();
}
// get value
$("#dom_overlay_container").on("change", "#A", A_change.bind(this));
// get submit if all input fields are filled in
$("#dom_overlay_container").on("keyup", "#A", checkIfDone.bind(this));

 

TOPICS
Code , How to

Views

809

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
community guidelines
LEGEND ,
Dec 04, 2019 Dec 04, 2019

Copy link to clipboard

Copied

To the best of my knowledge, CreateJS objects do not have the concept of focus.

Votes

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
community guidelines
LEGEND ,
Dec 04, 2019 Dec 04, 2019

Copy link to clipboard

Copied

Well, that's too bad. I guess I will try and find some way around.

Votes

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
community guidelines
Community Expert ,
Dec 04, 2019 Dec 04, 2019

Copy link to clipboard

Copied

Hi, res.

 

Yeah. I also agree that there isn't this concept of focus in CreateJS objects.

 

But if you already using DOM inputs, maybe you could also use a DOM button too. Then you're gonna be able to set the focus, I guess.

 

 

Regards,

JC

Votes

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
community guidelines
LEGEND ,
Dec 04, 2019 Dec 04, 2019

Copy link to clipboard

Copied

Good idea JC, in general but I am assigned art at work and I cannot change it. I might be able to copy it with CSS tho and definitely worth the try.

Votes

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
community guidelines
LEGEND ,
Dec 04, 2019 Dec 04, 2019

Copy link to clipboard

Copied

If the objective is just to submit when Enter is pressed, that's not hard.

var _this = this;

this.submitButton.addEventListener("click", submitClicked);
function submitClicked(evt) {
	evt.remove();
	window.removeEventListener("keydown", keyPressed);
	alert("CLICKED!");
}

window.addEventListener("keydown", keyPressed);
function keyPressed(evt) {
	if (evt.key.toLowerCase() === "enter") {
		_this.submitButton.dispatchEvent(new createjs.Event("click"));
	}
}

 

Votes

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
community guidelines
LEGEND ,
Dec 04, 2019 Dec 04, 2019

Copy link to clipboard

Copied

Thanks Clay

I have 6 input texts. The submit button should appear only when the 6 answers are filled in.

As far as checking the answers all is well. The problem I currently have is how to control the submit button whether it is visible or not.

I need to remove the submit button if the user deletes an answer and keeps it blank and then the button would be visible again if they fill in that blank answer since it would make 6 again.

Hope this makes sense.

 

PS right now even tho the input that are emptied of an answer do show as empty in the console, the new value is not read by the function for some reason. I wonder why.

Votes

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
community guidelines
LEGEND ,
Dec 05, 2019 Dec 05, 2019

Copy link to clipboard

Copied

Votes

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
community guidelines
LEGEND ,
Dec 05, 2019 Dec 05, 2019

Copy link to clipboard

Copied

LATEST

Well I ended using this and now it works just fine.

function checkHowMany() {
    if($(".A")[0].value != "" && $(".B")[0].value != "" && $(".C")[0].value != "" && $(".D")[0].value != "" && $(".E")[0].value != "" && $(".F")[0].value != "") {
        root.submitBtn3.visible = true;
    } else { 
        root.submitBtn3.visible = false;
    }
}

Votes

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
community guidelines