【问题标题】:Replace Input Textbox Text And Submit On "Enter" Key. - FLASH替换输入文本框文本并在“Enter”键上提交。 - 闪光
【发布时间】:2011-10-05 19:29:06
【问题描述】:

我正在为我的网站制作一个小横幅,根据地理位置(邮政编码)提供不同的优惠。除了我想要的一些元素外,我的代码几乎可以工作。

1) 我希望输入框显示“输入邮政编码”,直到用户点击输入框。然后它会被清除,用户可以输入他们的邮政编码。此时的文本框应该只包含 5 位数字,不能再多了。

2) 我希望用户也有一个选项,而不是必须单击按钮来提交表单,只需在输入文本字段上按 Enter 并处理表单即可。 任何关于如何做到这一点的帮助都会很棒! :-)

我正在使用带有 AS2 的 Flash CS5

这是我目前的代码:

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);

getURL(url, “_blank”, “GET”);
}

有什么想法吗?

【问题讨论】:

    标签: flash actionscript actionscript-2 flash-cs5


    【解决方案1】:
    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);
    

    【讨论】:

      猜你喜欢
      • 2012-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-29
      • 1970-01-01
      • 2017-12-15
      • 1970-01-01
      • 2011-12-22
      相关资源
      最近更新 更多