Forum Moderators: open

Message Too Old, No Replies

Two "onchange" forms on the same page

Two "onchange" forms on the same page

         

Chick

11:54 am on May 18, 2004 (gmt 0)

10+ Year Member



I have two pulldown lists on the same webpage, each with an onchange set in the select statement.

Both work fine.

However, when I select one, and then quickly click on the other before the first one changes the screen, I lose control and get a blank screen. After that, I have to refresh to use it again.

I am sure this is due to triggering both forms at once, but I need to either prevent it or make a check that captures it and restores the screen.

Can anyone help?

BlobFisk

12:07 pm on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, Chick!

How about setting the other select list to disabled as part of your onChange function? This should then eliminate this issue...

HTH

Chick

12:09 pm on May 18, 2004 (gmt 0)

10+ Year Member



Thanks, could you possibly post a short example of how to do that?

Alternative Future

12:13 pm on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Chick,

<script language="JavaScript">
<!--
function disable(what){
document.getElementById(what).disabled = true;
}
//-->
</script>

<select name="sel" onchange="disable('sel2')">
<option value="1">one</option>
<option value="2">two</option>
</select>
<br />
<select name="sel2" onchange="disable('sel')">
<option value="1">one</option>
<option value="2">two</option>
</select>

I was half way through doing this example when BlobFisk answered with the correct solution. So here is the example anyway...

Welcome to WebmasterWorld.

-George

Chick

12:16 pm on May 18, 2004 (gmt 0)

10+ Year Member



That's got to be the fastest answer I ever got!

You guys are awesome!

Thanks a ton :)

Chick

12:29 pm on May 18, 2004 (gmt 0)

10+ Year Member



Rats, it didn't work.

The disable works, because some radio buttons in the second form go dark when I click the first one, but touching the pulldown list in the second form still causes the white screen and lockup.

Alternative Future

12:34 pm on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you have unique ids for each element?

And my last example should have had id's assigned to them also like:
<select id="sel" onchange="disable('sel2')">

<select id="sel2" onchange="disable('sel')">

Try that and report back with some more info on where the bug takes places.

-George

Chick

12:45 pm on May 18, 2004 (gmt 0)

10+ Year Member



I had name= but I added id= and it had no effect that I can see.

I sent you a private message with instructions how to see the effect.

Chick

12:51 pm on May 18, 2004 (gmt 0)

10+ Year Member



<script language="JavaScript">
<!--
function disable(what){
document.getElementById(what).disabled = true;
}
//-->
</script>

<form method=post id="cmform" name="cmform" action="something">
<select name='comm' onchange="disable('dpform'); cmform.submit()">
<option selected>None</option>
<option value=1>One</option>
</select>
<br>
</form>
</td>
<td>
<br>
<form method=post id="dpform" name="dpform" action="something">
<select name='depot' onchange="disable('cmform'); dpform.submit()">
<option selected>None</option>
<option value=1>One</option>
</select>
<br>
</form>

Alternative Future

12:53 pm on May 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have you tried disabling the actual elements before the form?

At present you are disabling the form rather than the combo/select box. What happens when you try it like this:

select name='comm' id='comm' onchange="disable('depot')

select name='depot' id='depot' onchange="disable('comm')

Let's know the outcome of that please.

-George

Chick

1:00 pm on May 18, 2004 (gmt 0)

10+ Year Member



That did it!

You're the greatest!

Hmmm, I just realized, you did say put it on the Select, and I put it on the Form. Sorry for that.

Thanks again a zillion!