标签: button

javascript未捕获引用错误onclick

尝试使用按钮调用javascript函数,并且按钮在单击时没有执行任何操作.调试器返回"未捕获的引用错误:未定义printNumber.

printNumber 是我想要调用的函数.

我做了一个搜索,大多数有这个问题的人都没有使用正确的语法来声明它们的功能,在另一个函数中定义它们的函数(函数超出范围),或者在它们被调用之后放置它们的函数.事实证明我头脑中没有任何东西在运行.我试图在其中添加一个提示,但提示没有显示出来.

这是我的脚本:

    <head>
    <script type="javascript">
    var x=0;
    function addNumber(x){
        x = x + 1;
        return x;   
    }

    function printNumber(number){
        document.getElementById("number").innerHTML=addNumber(number);
    }

    </script>
    </head>
Run Code Online (Sandbox Code Playgroud)

这是我的HTML:

    <body>
<p><center><b>The number of times the button has been clicked is ... <b><p>
<br>
<div id="number"></div>
<br>
<form>
    <input type="button" id="StartButton" value="Click to add 1 to counter" onClick="printNumber(x)">
</form>
</center>
Run Code Online (Sandbox Code Playgroud)

任何人都可以向我指出问题的来源吗?谢谢,这是一个编程类,我希望其他可能遇到这个的人会看到这个.

html javascript function onclick button

6
推荐指数
1
解决办法
6万
查看次数

Android 5:softnavigation栏下面的按钮(Showcaseview legacy)

我正在使用传统的ShowcaseView for Android.我注意到Android 5模拟器将OK按钮放在softnavigation栏下面,而Android <= KITKAT没有这种行为.

请参见右下角的确定按钮:http://imgur.com/SZtIcHr

我已经尝试过android:fitsSystemWindows ="true"但没有成功.以下是我发现的ShowcaseView.java中的相关代码:

    mEndButton = (Button) LayoutInflater.from(context).inflate(R.layout.showcase_button, null);
Run Code Online (Sandbox Code Playgroud)

(警告:避免传递null作为视图根(需要解析膨胀布局的根元素上的布局参数))[..]

    if (!mOptions.noButton && mEndButton.getParent() == null) {
        RelativeLayout.LayoutParams lps = (LayoutParams) generateDefaultLayoutParams();
        lps.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
        if (getConfigOptions().showcaseId==3) 
            lps.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
        else
            lps.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
        int margin = ((Number) (metricScale * 12)).intValue();
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) // TODO: LOLLIPOP workaround
            lps.setMargins(margin, margin, margin, margin*5);
        else
            lps.setMargins(margin, margin, margin, margin);
        lps.height = LayoutParams.WRAP_CONTENT;
        lps.width = LayoutParams.WRAP_CONTENT;
        mEndButton.setLayoutParams(lps);
        mEndButton.setText(buttonText != null ? buttonText : getResources().getString(R.string.positive));
        if (!hasCustomClickListener) mEndButton.setOnClickListener(this); …
Run Code Online (Sandbox Code Playgroud)

android button material-design

6
推荐指数
1
解决办法
535
查看次数

如何隐藏Xcode 6中的按钮?

我想要做的就是隐藏一个按钮,直到按下另一个按钮.

例如,按钮1可见,但按钮2不可见.当我按下按钮1时,我需要按钮2出现.

另外,我使用Swift在Xcode 6中编程.

提前致谢!

xcode button ios swift

6
推荐指数
1
解决办法
1万
查看次数

使用按钮停止并启动循环

我试图控制我的程序中的while循环停止和启动基于用户输入.我用一个按钮尝试了这个,它的"开始"部分工作,但然后代码进入无限循环,我不能手动终止它.以下是我的所有代码: Header Class

package test;

    import javax.swing.JFrame;

    public class headerClass {
        public static void main (String[] args){
            frameClass frame = new frameClass();
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(150,75);
            frame.setVisible(true);
        }
    }
Run Code Online (Sandbox Code Playgroud)

框架类

package test;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class frameClass extends JFrame {

    private JButton click;

    public frameClass(){
        setLayout(new FlowLayout());
        click = new JButton("Stop Loop");
        add(click);

        thehandler handler = new thehandler();
        click.addActionListener(handler);
    }

    private class thehandler implements ActionListener{
        public void actionPerformed(ActionEvent e){
            if(e.getSource()==click){
                looper loop = new looper();
                looper.buttonSet = !looper.buttonSet; …
Run Code Online (Sandbox Code Playgroud)

java swing button while-loop

6
推荐指数
1
解决办法
2623
查看次数

Android Hexagon形状按钮,具有六边形触摸边界

我想在android中创建一个六边形形状按钮,这样它的触摸区域就不会重叠(在右边)ie.I希望heaxagon触摸绑定不是一个矩形触摸界限.我试图使用图像视图,但它不排除透明(以蓝色,左侧显示).是否存在由xml shape/path定义的可点击对象.如果有可能或任何其他方法,请任何人只显示一个按钮的xml形状/路径部分.在此输入图像描述

xml user-interface android button

6
推荐指数
1
解决办法
5568
查看次数

Yii2按钮点击匿名功能

我是Yii2的新手,我正在努力通过按Yii2按钮来触发匿名功能.下面是6个样本,其中前两个是好的.但这并不是我想要的.我想知道如何让一个匿名函数工作,比如"Button 3"和"Button 5"的情况.我测试了如何通过Controller进行函数调用,这样可以正常工作,但这不是我想要的.非常感谢你的帮助 - 谢谢!

// This works
$button1 = Button::begin ( 
[
'label' => 'Button 1',
'options' => [
    'class' => 'btn btn-primary',
    'onclick' => 'alert("Button 1 clicked");',
    ],
]);
$button1->run();

// This works
echo Html::button('Button 2', [ 'class' => 'btn btn-primary', 'onclick' => 'alert("Button 2 clicked");' ]);

// This DOES NOT work
echo Html::button('Button 3', [ 'class' => 'btn btn-primary', 'onclick' => 'function ( $event ) { alert("Button 3 clicked"); }' ]);

// This DOES NOT work
$button4 …
Run Code Online (Sandbox Code Playgroud)

javascript anonymous function button yii2

6
推荐指数
1
解决办法
2万
查看次数

添加Gmail应用程序的"新邮件"按钮等按钮

我想添加一个按钮,例如Gmail应用程序中的"新邮件"按钮(带有钢笔图标的右下方圆圈按钮),该按钮浮动在屏幕上.有人能告诉我怎么做吗?没有材料设计指南可以做到这一点吗?

在此输入图像描述

android button material-design

6
推荐指数
1
解决办法
4703
查看次数

按钮在第一次单击时不起作用

function showCheckbox(){  
    var node_list = document.getElementsByClassName('check');
    for (var i = 0; i < node_list.length; i++) 
    {  
      if(node_list[i].style.display == 'none') { 
        node_list[i].style.display = 'block';
      } else { node_list[i].style.display = 'none'; }
    }
}
Run Code Online (Sandbox Code Playgroud)
input[type=checkbox]{
display:none;
position:relative;
}
Run Code Online (Sandbox Code Playgroud)
<input type="button"  value="????????" onclick="showCheckbox()" />
<img src="form-images\trash.png"  onclick="" style="width:21px;height:24px;margin-left:20px; "/>

    <input type="checkbox" class="check" />   
        <label>??????</label>
        <input type="text"  />
   	</br>
	<input type="checkbox" class="check" />   
        <label>??????</label>
        <input type="text"/>
      </br>
Run Code Online (Sandbox Code Playgroud)

当页面第一次加载并且我在第一次单击时按下按钮它不会触发onclick功能.如果我按下它会触发事件的时间.

其他按钮在第一次单击时触发事件没有问题.有谁知道问题是什么,或者他有同样的问题吗?

html javascript html5 button javascript-events

6
推荐指数
1
解决办法
1万
查看次数

CKEDITOR - 带文字的工具栏按钮

我有一个插件来通过Ajax保存编辑器内容.现在,工具栏上的按钮有一个图像.我想改变它,让大胆的文字拼写出'SAVE'.这可能吗?

这是我的插件中的按钮.

    editor.ui.addButton('ajax-save', {
      label: I18n.t('js.save'),
      command: ajax-save,
      className : 'cke_ajax_save'
    });
Run Code Online (Sandbox Code Playgroud)

plugins text toolbar button ckeditor

6
推荐指数
1
解决办法
2138
查看次数

如何在Android中制作彼此重叠的自定义形状按钮

我有6个单独的图像与透明背景.如何将所有这些图像组合在一起作为按钮,如:

在此输入图像描述

从我读到的,我想我必须使用框架布局,以便有重叠的按钮.

点击时我需要每种颜色都是一个单独的按钮.

更新:我做了一个演示并检查onclick方法中的透明然而当我点击红色和蓝色交叉点附近的红色区域时,由于重叠视图,它没有注册红色按钮是单击.请帮忙!

https://www.dropbox.com/s/fc98nnnfbrtdh82/Photo%20Apr%2016%2C%202%2002%2013.jpg?dl=0

public boolean onTouch(View v,MotionEvent event){

                                     int eventPadTouch = event.getAction();
                                     int iX = (int)event.getX();
                                     int iY = (int)event.getY();          
                                     switch (eventPadTouch) {

                                         case MotionEvent.ACTION_DOWN:

                                             if (iX>=0 & iY>=0 & iX<TheBitmap.getWidth() & iY<TheBitmap.getHeight()&TheBitmap.getPixel(iX,iY)!=0) {
                                                 if (TheBitmap.getPixel(iX,iY)!=0) {
                                                     Toast.makeText(getApplicationContext(),"clicked blue",Toast.LENGTH_LONG).show();

                                                 }
                                             }
                                             return true;
                                     }

                                     return false;
                                 }
                             }
Run Code Online (Sandbox Code Playgroud)

android button android-imagebutton

6
推荐指数
1
解决办法
1153
查看次数