开发者

Replace Input Textbox Text And Submit On "Enter" Key. - FLASH

开发者 https://www.devze.com 2023-04-11 14:20 出处:网络
I am making a little banner for my site that makes different offers based on geo location (zipcode). I have the code working pretty much except for a few elements I want.

I am making a little banner for my site that makes different offers based on geo location (zipcode). I have the code working pretty much except for a few elements I want.

1) I want the input box to say “Enter Zip Code” until the user clicks on the input box. Then it clears out and the user can enter their zip code. The text box at this point should only take in 5 digits and no more.

2) Instead of having to click on the button to submit the form I want the user to also have an option just press enter when they are on the input text field and it process the form. Any help on how do to do this would be amazing! :-)

I am using Flash CS5 with AS2

This is the code I have so far:

nameText = “zip”;
zipCode.text = nameText;
zipCode.onSetFocus = function(){
if(this.text == nameText) {
this.text = “”;
}
}
zipCode.onKillFocus = function(){
  if (this.text == “”){
      this.text = nameText;
  }
}
gobutton.onPress = function(){
var zipcode:String = zipCode.text; //input text box
var link:String = “http://www.mycoolwebsite.com&zipcode;=”; //the site
var url:String = link + zipcode; // The site + the input text box
trace(url);

get开发者_开发技巧URL(url, “_blank”, “GET”);
}

Any Thoughts?


function checkURL(){
var zipcode:String = zipCode.text; //input text box
var link:String = "mywebsiteURL&zipcode="; //the site
var url:String = link + zipcode; // The site + the input text box

trace(url);

getURL(url, "_blank", "GET");
}

keyListener = new Object();

gobutton.onPress = function(){
checkURL();
}

keyListener.onKeyDown = function(){
if(Key.isDown(Key.ENTER)){
    checkURL();
}
}

Key.addListener(keyListener);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号