423,680 Members | 2,394 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,680 IT Pros & Developers. It's quick & easy.

Disable drag in ie & FF

P: n/a
Im not sure if this is the group to post in, if anyone knows a more
appropriate one please let me know.

Please consider the following example of a feature most all browsers
have that I would like to either disable or find a work around for.

Background:
I have a form that has 3 input type="text" fields. The fields are
Quantity, Amount and total. OnKeyUp is used when you enter something in
Quantity or Amount to trigger a javaScript function that makes a
calculation and updates the total field.

The total field is "locked" with onFocus=this.blur so that the totals
cannot be entered by the end user. I did not use disable because when
the form is submitted I had problems with asp form collection of
disabled form elements.

Issue:
1. If you highlight the number you entered for Amount in the form field
then left click and drag it will (copy/cut depending on browser and
version) the Amount field into the "locked" total field.

2. If you click drag as described above the Amount into the next Amount
field the total will not be calculated because a key event was not used
to move the data thus the javaScript function to do the calculation was
not fired.

The client "must have" the calculations being done real time so the
people entering the time can see the total entered.

Any ideas on working around this would be greatly appreciated.

Earl

Nov 25 '06 #1
Share this Question
Share on Google+
9 Replies


P: n/a
surf_doggie wrote:
Issue:
1. If you highlight the number you entered for Amount in the form field
then left click and drag it will (copy/cut depending on browser and
version) the Amount field into the "locked" total field.

2. If you click drag as described above the Amount into the next Amount
field the total will not be calculated because a key event was not used
to move the data thus the javaScript function to do the calculation was
not fired.

The client "must have" the calculations being done real time so the
people entering the time can see the total entered.

If you absolutely have to have a total field for your submit form,
consider making it hidden. Next use a <div id=someIDor <span
id=someIDto hold your totals, then when you calculate your totals,
after you update the value in your hidden field just do
document.getElementById("someID").innerHTML = newtotal;

This eliminates the problem by preventing total from being an input
field and making it a part of the web page itself.
---------------------------------------------------------------------------
http://www.hunlock.com -- Permanently under construction (And proud of it!)
$FA
Nov 25 '06 #2

P: n/a
Client wants the people to be able to see the totals before they submit
so hidden total is not an option, if it were I wouldnt calculate with
JS would do it server side. Its a good idea and I would do it but its
not an option in this situation.

pcx99 wrote:
surf_doggie wrote:
Issue:
1. If you highlight the number you entered for Amount in the form field
then left click and drag it will (copy/cut depending on browser and
version) the Amount field into the "locked" total field.

2. If you click drag as described above the Amount into the next Amount
field the total will not be calculated because a key event was not used
to move the data thus the javaScript function to do the calculation was
not fired.

The client "must have" the calculations being done real time so the
people entering the time can see the total entered.


If you absolutely have to have a total field for your submit form,
consider making it hidden. Next use a <div id=someIDor <span
id=someIDto hold your totals, then when you calculate your totals,
after you update the value in your hidden field just do
document.getElementById("someID").innerHTML = newtotal;

This eliminates the problem by preventing total from being an input
field and making it a part of the web page itself.
---------------------------------------------------------------------------
http://www.hunlock.com -- Permanently under construction (And proud of it!)
$FA
Nov 25 '06 #3

P: n/a
surf_doggie wrote:
Client wants the people to be able to see the totals before they submit
so hidden total is not an option, if it were I wouldnt calculate with
JS would do it server side. Its a good idea and I would do it but its
not an option in this situation.
As I said. Make the total input field hidden but create a <divor
<spanon the web page and use DHTML to insert the new total directly
into the web page. This prevents the total from being a visible
textbox and makes the total a part of the web page itself just like any
other text.
Nov 25 '06 #4

P: n/a

pcx99 wrote:
surf_doggie wrote:
Client wants the people to be able to see the totals before they submit
so hidden total is not an option, if it were I wouldnt calculate with
JS would do it server side. Its a good idea and I would do it but its
not an option in this situation.

As I said. Make the total input field hidden but create a <divor
<spanon the web page and use DHTML to insert the new total directly
into the web page. This prevents the total from being a visible
textbox and makes the total a part of the web page itself just like any
other text.
I see said the blind man. I will test that out but what about the
function not firing when you use the copy feature mentioned above to
move one amount to another amount field?

Nov 25 '06 #5

P: n/a

surf_doggie wrote:
pcx99 wrote:
surf_doggie wrote:
Client wants the people to be able to see the totals before they submit
so hidden total is not an option, if it were I wouldnt calculate with
JS would do it server side. Its a good idea and I would do it but its
not an option in this situation.
As I said. Make the total input field hidden but create a <divor
<spanon the web page and use DHTML to insert the new total directly
into the web page. This prevents the total from being a visible
textbox and makes the total a part of the web page itself just like any
other text.

I see said the blind man. I will test that out but what about the
function not firing when you use the copy feature mentioned above to
move one amount to another amount field?
Never mind testing all the fields this way. Will repost shortly

Nov 25 '06 #6

P: n/a
"surf_doggie" <ea*******@gmail.comwrites:
I have a form that has 3 input type="text" fields. The fields are
Quantity, Amount and total. OnKeyUp is used when you enter something in
Quantity or Amount to trigger a javaScript function that makes a
calculation and updates the total field.

The total field is "locked" with onFocus=this.blur so that the totals
cannot be entered by the end user. I did not use disable because when
the form is submitted I had problems with asp form collection of
disabled form elements.
What is the oldest browser you're trying to support? You can simply
disable an input control with disabled="disabled" in the HTML or with
control.disabled=true in JS. Also, as pcx suggested, why not use a div
to display the result of your calculation?
Issue:
1. If you highlight the number you entered for Amount in the form field
then left click and drag it will (copy/cut depending on browser and
version) the Amount field into the "locked" total field.
You can disable drag and drop in IE by handling two non-standard
events, ondragover and ondrop. In FF, to the best of my knowledge, you
can't override default DnD behaviors unless you use XUL to describe at
least part of your document.

In any case, I have a feeling that you don't need to deal with DnD as
such, just as long as the element you use to display your results is
not an input or is disabled.
2. If you click drag as described above the Amount into the next Amount
field the total will not be calculated because a key event was not used
to move the data thus the javaScript function to do the calculation was
not fired.
Are you using onkeyup? Try onchange.

Ari.
--
Elections only count as free and trials as fair if you can lose money
betting on the outcome.
Nov 25 '06 #7

P: n/a

Ari Krupnik wrote:
"surf_doggie" <ea*******@gmail.comwrites:
I have a form that has 3 input type="text" fields. The fields are
Quantity, Amount and total. OnKeyUp is used when you enter something in
Quantity or Amount to trigger a javaScript function that makes a
calculation and updates the total field.

The total field is "locked" with onFocus=this.blur so that the totals
cannot be entered by the end user. I did not use disable because when
the form is submitted I had problems with asp form collection of
disabled form elements.

What is the oldest browser you're trying to support? You can simply
disable an input control with disabled="disabled" in the HTML or with
control.disabled=true in JS. Also, as pcx suggested, why not use a div
to display the result of your calculation?
Issue:
1. If you highlight the number you entered for Amount in the form field
then left click and drag it will (copy/cut depending on browser and
version) the Amount field into the "locked" total field.

You can disable drag and drop in IE by handling two non-standard
events, ondragover and ondrop. In FF, to the best of my knowledge, you
can't override default DnD behaviors unless you use XUL to describe at
least part of your document.

In any case, I have a feeling that you don't need to deal with DnD as
such, just as long as the element you use to display your results is
not an input or is disabled.
2. If you click drag as described above the Amount into the next Amount
field the total will not be calculated because a key event was not used
to move the data thus the javaScript function to do the calculation was
not fired.

Are you using onkeyup? Try onchange.

Ari.
--
Elections only count as free and trials as fair if you can lose money
betting on the outcome.
I tried the onchange but when dragging from an amount field to an
amount field it does not fire the function

Nov 25 '06 #8

P: n/a
Figured it out

<input name="expQuant0" type="text" size="2" value="1"
onKeyUp="calc_Exp(this.name,this.value,event);"
onFocus="clearbox(this.name,this.value);"
onBlur="setbox(this.name,this.value,'exp');" ondragstart="return
false;" >

Key is to add ondragstart="return false;" that you dont want dragable.

Thanks,
Earl

surf_doggie wrote:
Ari Krupnik wrote:
"surf_doggie" <ea*******@gmail.comwrites:
I have a form that has 3 input type="text" fields. The fields are
Quantity, Amount and total. OnKeyUp is used when you enter something in
Quantity or Amount to trigger a javaScript function that makes a
calculation and updates the total field.
>
The total field is "locked" with onFocus=this.blur so that the totals
cannot be entered by the end user. I did not use disable because when
the form is submitted I had problems with asp form collection of
disabled form elements.
What is the oldest browser you're trying to support? You can simply
disable an input control with disabled="disabled" in the HTML or with
control.disabled=true in JS. Also, as pcx suggested, why not use a div
to display the result of your calculation?
Issue:
1. If you highlight the number you entered for Amount in the form field
then left click and drag it will (copy/cut depending on browser and
version) the Amount field into the "locked" total field.
You can disable drag and drop in IE by handling two non-standard
events, ondragover and ondrop. In FF, to the best of my knowledge, you
can't override default DnD behaviors unless you use XUL to describe at
least part of your document.

In any case, I have a feeling that you don't need to deal with DnD as
such, just as long as the element you use to display your results is
not an input or is disabled.
2. If you click drag as described above the Amount into the next Amount
field the total will not be calculated because a key event was not used
to move the data thus the javaScript function to do the calculation was
not fired.
Are you using onkeyup? Try onchange.

Ari.
--
Elections only count as free and trials as fair if you can lose money
betting on the outcome.

I tried the onchange but when dragging from an amount field to an
amount field it does not fire the function
Nov 26 '06 #9

P: n/a
ASM
surf_doggie a écrit :
what about the
function not firing when you use the copy feature mentioned above to
move one amount to another amount field?

Quantity : <input onchange="calculate()" blah />

or if you think it's better :

<input onkeyup="calculate()" onchange="calculate()" blah />
or
<input onkeyup="calculate()" onmouseup="calculate()" blah />

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Contact : http://stephane.moriaux.perso.wanadoo.fr/contact
ASM = Aimable Stéphane Moriaux = Amateur Sasseur Merdouilles
Nov 26 '06 #10

This discussion thread is closed

Replies have been disabled for this discussion.