逻辑和禁用onclicks? [英] logic and disabling onclicks?

查看:68
本文介绍了逻辑和禁用onclicks?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我不清楚如何解决这个问题。


说中间的C片被播放,只需一次。


然后当用户点击播放图像时,播放一系列音符

从中间C开始,用户必须说明用户是否

最后一个声音与第一个声音相同或不同。这套有4套




我可以很容易地做到这一点,每套4套,播放图像和

相同和不同的图像。调用这些A,B,C和D.用户点击播放图像来听取一系列声音然后在

相同或不同的图像上点击

。 br />

困难在于如何防止用户,当想知道情况A的答案时,谁决定点击播放按钮B到

提醒他/她C音符是什么样的。


因此,点击A的播放图像后只有相同和不同的

A的图像启用了他们的onclick事件。 B,C和D的播放,相同和

不同的图像都禁用了它们。


点击B的播放图像时唯一的图像onclick

事件启用是B等的相同和不同的图像。


任何想法都可以!?


干杯,


Geoff

Hello,

I am not at clear how to tackle this one.

Say the note middle C is played, just once.

Then when the user clicks on a play image a series of notes are played
starting with middle C and the user the user has to say whether the
last sound is the same as the first or different. There are 4 sets of
this.

I can do this easily enough with 4 sets each with the play image and a
same and different image. Call these A, B, C and D. The user clicks
the play image to hear the series of sounds and then on either the
same or the different image.

The difficulty is in how to prevent the user, who when wondering about
the answer to situation A, decides to click the play button for B to
remind him/herself what the note C sounds like.

So, after clicking the play image for A only the same and different
images for A have their onclick events enabled. The play, same and
different images for B, C and D have their onlicks disabled.

On clicking the play image for B the only images for which the onclick
event is enabled are the same and different images for B, etc etc .

Any ideas please!?

Cheers,

Geoff

推荐答案

在comp.lang.javascript消息< o1m804dtgo225f9squr49dpa8mieuh80ke @ 4ax。

com> ;,星期二,2008年4月15日08:26:08,Geoff Cox< gc ** @ freeuk.notcomposted:
In comp.lang.javascript message <o1m804dtgo225f9squr49dpa8mieuh80ke@4ax.
com>, Tue, 15 Apr 2008 08:26:08, Geoff Cox <gc**@freeuk.notcomposted:

>
我现在有了更一般的代码,但是无法看到如何防止用户点击第二,第三或第四个播放图像同时回答第一次测试?
>
I have now got the code more general but cannot see how to prevent
user clicking the second, third or fourth play images whilst answering
the first test?



你似乎有一种无序的方法。


AIUI,你有一定数量的准按钮和限制

序列,可以使用它们。每组限制都需要作为一个内部状态持有
。在你的情况下,可能是状态

仅由最后按下哪个按钮决定。


通常,大多数按钮应该是被禁用;所以make

undefined相当于off。


创建一个数组,由状态0..N索引,其中每个元素本身就是

允许的按钮ID数组。


var Arry = [

/ *状态0:* / [" B1", B2,B3,B4,

/ *状态1:* / [" B1"," B2"],

// ...

/ *状态N:* / [" B5"," B6"]]


在每个Click事件中,确定新状态,并调用一个例程,即

禁用所有按钮,然后启用数据中提到的那些

状态。对于第一部分,可以简化为阵列Btns

命名所有按钮。


要更改规则,您现在只需要更改文字分配

到A.


函数X(状态){var J,D = Arr [状态]

for( J in Btns){} //禁用Btns [J]

for(J in Arry){} //启用Arry [J]

}

我认为你可以通过在开始时创建

来节省时间(无关紧要),该对象由持有getElementById(ID)的

结果的按钮ID索引。


您可以使用由普通按钮组成的虚拟系统来测试它。每次都会报告其内部结构。


-

(c)约翰斯托克顿,英国伦敦。 ?@merlyn.demon.co.uk BP7,Delphi 3& 2006.

< URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/& c。,FAQqy主题&链接;

< URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htmclpdmFAQ;

< URL:http://www.borland。 com / newsgroups / guide.htmlnews:borland。*指南

You seem to have a disorderly approach.

AIUI, you have a quantity of quasi-buttons, and restrictions on the
sequence in which they may be used. Each set of restrictions needs to
be held as an internal state. It may be, in your case, that the state
is determined solely by which button was last pressed.

It seems that, generally, most buttons should be disabled; so make
undefined equivalent to off.

Create an array, indexed by state 0..N, in which each element is itself
an array of IDs of buttons to be allowed.

var Arry = [
/* State 0 : */ ["B1", "B2", "B3", "B4"],
/* State 1 : */ ["B1", "B2"],
// ...
/* State N : */ ["B5", "B6"] ]

In each Click event, determine the new State, and call a routine which
disables all buttons and then enables the ones mentioned in the data for
that State. It may simplify to have, for the first part, an array Btns
naming all buttons.

To change your Rules, you now merely have to alter the literal assigned
to A.

function X(State) { var J, D = Arr[State]
for (J in Btns) { } // disable Btns[J]
for (J in Arry) { } // enable Arry[J]
}
I think you could possibly save time (irrelevantly) by creating
at the start an Object indexed by the button IDs holding the
results of getElementById(ID).

You can test that out with a dummy system consisting of ordinary buttons
and reporting on its innards each time.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk BP7, Delphi 3 & 2006.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.bancoems.com/CompLangPascalDelphiMisc-MiniFAQ.htmclpdmFAQ;
<URL:http://www.borland.com/newsgroups/guide.htmlnews:borland.* Guidelines


2008年4月15日星期二20:43:50 +0100,JR Stockton博士

< jr*@merlyn.demon.co.ukwrote:
On Tue, 15 Apr 2008 20:43:50 +0100, Dr J R Stockton
<jr*@merlyn.demon.co.ukwrote:

>在comp.lang.javascript消息< o1m804dtgo225f9squr49dpa8mieuh80ke @ 4ax。
com>,Tue,2008年4月15日08:26:08,Geoff Cox< gc ** @ freeuk.notcomposted:
>In comp.lang.javascript message <o1m804dtgo225f9squr49dpa8mieuh80ke@4ax.
com>, Tue, 15 Apr 2008 08:26:08, Geoff Cox <gc**@freeuk.notcomposted:

>>
我现在有了更一般的代码但是看不出如何防止用户点击第二,第三或第四个播放图像同时回答第一次测试?
>>
I have now got the code more general but cannot see how to prevent
user clicking the second, third or fourth play images whilst answering
the first test?


你似乎有一种无序的方法。


You seem to have a disorderly approach.



...我必须同意!我正在一个侧翼和祈祷......

现在会考虑你的建议。谢谢。


Geoff

...that I must agree with! I am moving along on a wing and a prayer ...
will give some thought now to your suggestions. Thanks.

Geoff


>
AIUI,你有一定数量的准按钮和限制在它们可能被使用的序列上。每组限制都需要作为内部状态进行。在你的情况下,状态可能只取决于最后按下哪个按钮。

通常,大多数按钮应该被禁用;所以make
undefined等同于off。

创建一个数组,由状态0..N索引,其中每个元素本身是一个允许的按钮ID数组。

var Arry = [
/ *状态0:* / [" B1"," B2"," B3"," B4"],
/ *状态1:* / [" B1"," B2"],
// ...
/ *状态N:* / [" B5"," B6"] ]

在每个Click事件中,确定新状态,并调用一个例程,该例程将禁用所有按钮,然后启用
该状态数据中提到的例程。对于第一部分,可以简化为阵列Btns命名所有按钮。

要更改您的规则,您现在只需要更改指定的文字


函数X(状态){var J,D = Arr [状态]

for(J in Btns){} //禁用Btns [J]

for(J in Arry){} //启用Arry [J]

}


我认为你可以节省时间(无关紧要) )通过在开始时创建

,由按钮ID索引的Object保存getElementById(ID)的

结果。

您可以测试用一个由普通按钮组成的虚拟系统,并每次报告其内部结构。
>
AIUI, you have a quantity of quasi-buttons, and restrictions on the
sequence in which they may be used. Each set of restrictions needs to
be held as an internal state. It may be, in your case, that the state
is determined solely by which button was last pressed.

It seems that, generally, most buttons should be disabled; so make
undefined equivalent to off.

Create an array, indexed by state 0..N, in which each element is itself
an array of IDs of buttons to be allowed.

var Arry = [
/* State 0 : */ ["B1", "B2", "B3", "B4"],
/* State 1 : */ ["B1", "B2"],
// ...
/* State N : */ ["B5", "B6"] ]

In each Click event, determine the new State, and call a routine which
disables all buttons and then enables the ones mentioned in the data for
that State. It may simplify to have, for the first part, an array Btns
naming all buttons.

To change your Rules, you now merely have to alter the literal assigned
to A.

function X(State) { var J, D = Arr[State]
for (J in Btns) { } // disable Btns[J]
for (J in Arry) { } // enable Arry[J]
}
I think you could possibly save time (irrelevantly) by creating
at the start an Object indexed by the button IDs holding the
results of getElementById(ID).

You can test that out with a dummy system consisting of ordinary buttons
and reporting on its innards each time.


在comp.lang.javascript消息< hn4b04dp2ajt4dr5gmlmsc2dqgabdpth2f @ 4ax。

com>,Wed,2008年4月16日06: 53:19,Geoff Cox< gc ** @ freeuk.notcomposted:
In comp.lang.javascript message <hn4b04dp2ajt4dr5gmlmsc2dqgabdpth2f@4ax.
com>, Wed, 16 Apr 2008 06:53:19, Geoff Cox <gc**@freeuk.notcomposted:

>
我看不出如何使用你的建议!

您是否有机会使用建议的方法指出任何代码?这可能会让我开始这条路线。
>
I cannot see how to get going using your suggestions!

Any chance that you can point me at any code using your suggested
approach? That might get me started on that route.



这就像我建议的那样,除了所有控件都调用单个

处理程序Fn,它在处理Enables之后调用main例程由AB C代表的
。按钮同样可以称为个人

处理程序,每个处理程序最初调用Fn而没有最后一个语句。

测试IE7 ,FF2,Op9,Sf3,OK:由于遗漏而没有通过W3 TIDY。


但它与我之前写的完全不符;还有

各种类似的方法,有类似的功能。

< form>

< input type = button name = QUOT; B0" value = 0 onClick =" Fn(this)">

< input type = button name =" B1" value = 1 onClick =" Fn(this)">

< input type = button name =" B2" value = 2 onClick =" Fn(this)">

< input type = button name =" B3" value = 3 onClick =" Fn(this)">

< input type = button name =" B4" value = 4 onClick =" Fn(this)">

< input type = button name =" B5" value = 5 onClick =" Fn(this)">

< input type = button name =" B6" value = 6 onClick =" Fn(this)">

< input type = button name =" B7" value = 7 onClick =" Fn(this)">

< br>

州,结果:<输入类型=文字名称= S>

< / form>


< script>


var Arry = [

/ *状态0:* / [0,1,2,3],

/ *状态1:* / [2],

/ *状态2 :* / [3],

/ *状态3:* / [4],

/ *状态4:* / [5,6,7],

/ *状态5:* / [6,2],

/ *状态6:* / [7,2],

/ *状态7:* / [0]]


函数A(f){fSvalue + =",Hay" } b / b
函数B(f){f.S.value + =",Bee" }

函数C(f){f.S.value + =",Sea" }

函数Z(f){f.S.value + =",Zed" }


DoSpecificTask = [A,B,C,B,A,B,C,Z]


函数Fn(Arg){ var F = Arg.form,State,J,Next

FSvalue = State = Arg.value //或= Func(Arg.value,State)

for( J = 0; J <8; J ++)F [" B" + J] .disabled =" disabled" //全部清除

下一个= Arry [州]

for(下一个J)F [" B" + [J]]。禁用="" ; //设置一些

DoSpecificTask [State](F)}


< / script>

修改指示的部分if状态取决于最后按下哪个按钮




进行测试,选择是否可能使用Opera或Safari,因为按钮看起来很好

更好。


-

(c)John Stockton,nr伦敦英国。 ?@merlyn.demon.co.uk Turnpike v6.05 MIME。

< URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/& c 。,FAQqy主题&链接;

< URL:http://www.merlyn.demon.co.uk/clpb-faq.txt RAH Prins:clpb mFAQ;

< URL :ftp://garbo.uwasa.fi/pc/link/tsfaqp.zipTimo Salmi'的Turbo Pascal FAQ。

This is much as I suggested, except that all controls call a single
handler, Fn, which after handling the Enables calls the main routines
represented by A B C. The buttons could equally well call individual
handlers which each initially call Fn without its last statement.
Tested IE7, FF2, Op9, Sf3, OK : does not pass W3 TIDY, due to omissions.

But it does not correspond exactly with what I wrote before; there are
various similar ways, of similar merit, of doing the job.
<form>
<input type=button name="B0" value=0 onClick="Fn(this)">
<input type=button name="B1" value=1 onClick="Fn(this)">
<input type=button name="B2" value=2 onClick="Fn(this)">
<input type=button name="B3" value=3 onClick="Fn(this)">
<input type=button name="B4" value=4 onClick="Fn(this)">
<input type=button name="B5" value=5 onClick="Fn(this)">
<input type=button name="B6" value=6 onClick="Fn(this)">
<input type=button name="B7" value=7 onClick="Fn(this)">
<br>
State, Result : <input type=text name=S>
</form>

<script>

var Arry = [
/* State 0 : */ [0, 1, 2, 3],
/* State 1 : */ [2],
/* State 2 : */ [3],
/* State 3 : */ [4],
/* State 4 : */ [5, 6, 7],
/* State 5 : */ [6, 2],
/* State 6 : */ [7, 2],
/* State 7 : */ [0] ]

function A(f) { f.S.value += ", Hay" }
function B(f) { f.S.value += ", Bee" }
function C(f) { f.S.value += ", Sea" }
function Z(f) { f.S.value += ", Zed" }

DoSpecificTask = [A, B, C, B, A, B, C, Z]

function Fn(Arg) { var F = Arg.form, State, J, Next
F.S.value = State = Arg.value // or = Func(Arg.value, State)
for (J=0 ; J<8 ; J++) F["B"+J].disabled = "disabled" // clear all
Next = Arry[State]
for (J in Next) F["B"+Next[J]].disabled = "" // set some
DoSpecificTask[State](F) }

</script>
Modify the indicated part if the State depends on more than which button
was pressed last.

For test, choose if possible Opera or Safari, because the buttons look
nicer there.

--
(c) John Stockton, nr London UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zipTimo Salmi''s Turbo Pascal FAQ.


这篇关于逻辑和禁用onclicks?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆