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

if/else statement not recognizing text input component

Explorer ,
Dec 25, 2019 Dec 25, 2019

Copy link to clipboard

Copied

Just a bump of my old topic. I'm using the built in text input field component with an if else statement. First see my code:

 

this.button1.addEventListener('click', bF.bind(this));
function bF(){
	if (this.toName.text == "") {
		this.status.text = "please enter a to name";
	} else {
		this.gotoAndStop(1);
		this.status.text = "Sending Ecard - Please Hold";
}}

 

(this is just a quick sample)
status is a dynamic textbox and correctly displays its message of sending ecard.

toName is the text input component... and it's being completely ignored. even left blank, it still pushes the sending message. just to test, i made toName a dynamic text and left it blank, the above code recognized it as blank and status gave me "please enter..."

now I'm not sure, but maybe I have to utilize this following code somehow... maybe someone out there knows?:

 

dom_overlay_container.children["toName"].???;

 

the ??? just means "can I put something here that lets my if else statement recognize it the same way it recognizes my dynamic text example?" 

 

Thanks for your time!

TOPICS
Code

Views

751

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

correct answers 1 Correct answer

Community Expert , Dec 25, 2019 Dec 25, 2019

use the code snippets to see how to reference components.  in your case,you would see you should use:

 

if($('#toName').val()== ""){  // if toName is an input tf component

$('#status).val('please enter a to name');  // if status is an input tf component. 

this.status.text = "please enter a to name" ;  // if status is a dynamic tf 

} else {

etc

}

Votes

Translate

Translate
Community Expert ,
Dec 25, 2019 Dec 25, 2019

Copy link to clipboard

Copied

use the code snippets to see how to reference components.  in your case,you would see you should use:

 

if($('#toName').val()== ""){  // if toName is an input tf component

$('#status).val('please enter a to name');  // if status is an input tf component. 

this.status.text = "please enter a to name" ;  // if status is a dynamic tf 

} else {

etc

}

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
Explorer ,
Dec 25, 2019 Dec 25, 2019

Copy link to clipboard

Copied

Woah I was way off xD  Thanks a million and Merry Christmas. This indeed worked. I do have one last question, however it might need its own topic... but taking a shot in the dark, maybe I can tinker with it during the break..


The old AS code in the button was this.

loadVariablesNum ("SendEcard.php", 0, "POST");


There wouldn't happen to be a JS equivalent to this would there?
 

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 26, 2019 Dec 26, 2019

Copy link to clipboard

Copied

LATEST

no, that as2 code won't work. you'll need to use javascript when creating html5/canvas applications.

 

because you're using a component, animate adds jquery (a helper library) to your project and jquery is much easier to use than javascript.  in fact, you could use:

 

$.load("SendEcard.php", function(response, status, xhr) {

if (status == "error") {

console.log(xhr.status + " " + xhr.statusText);

} else if(status == "success"){

parseF(response);

}

});

 

function parseF(r){

// handle the return r from your php file

}

 

 

 

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