• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

onpaste event in a drop down list

 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everybody!

In IE9 I need to capture the paste event in a drop down list through JavaScript, but I hadn't positive results. I can capture the even in a text field or a textarea one, but with a drop down list it has been impossible. Neither the Ctrl+v nor the Paste option on context menu have been captured. I've tried to use the HTML [<ELEMENT onpaste="handler">] and the JavaScript [object.addEventListener ("paste", handler, useCapture);] ways to declare the handler with the same result.

What I'm trying to do is capture that event, parse the pasted text (in a specific format) and generate the suitable options elements according with the pasted text.

I wonder if you could say me how to capture that event for a drop down list, if it is possible.


Thank you in advance for all your answers.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where would you paste into a drop down? A drop down is a select tag which doesn't allow you to enter data only select what is there. Or are we talking about some other construct?
 
Marco Antonio
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

First of all, thank you for you interest.

About my question, I don't matter where the user paste the mentioned formated text, whether the drop down list is collapsed or expanded. What I need is capture the paste event in a drop down list.

I have been looking for documentation about this, and the <select> element accept that event.

http://help.dottoro.com/ljuimtmq.php#supByObj

or

http://msdn.microsoft.com/en-us/library/ie/ms535893(v=vs.85).aspx#events

However, the event is not captured when I paste something neither the Ctrl+v shortcut nor the Paste option on context menu. I have tried to paste the text with the drop down list collapsed, expanded, with options, empty, with multiple selection, with single one, etc.

If the <select> element accept the event, why cannot it be captured? Is it definitely impossible? In this case, why does it accept the event? In what cases it can be used?


Thank you so much.
 
Jeanne Boyarsky
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting. The w3c says the paste event triggers even on a non-editable element. I agree that doesn't appear to be happening though.

I was thinking to suggest you use a transparent div. However, this example with a div works for me in Chrome and not Safari.

I'm still not clear on what you are trying to accomplish though. Why would a user logically try to paste over a select list?
 
Marco Antonio
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you, Jeanne.

Yes, it is interesting that a non editable element can capture the paste event, and it is more interesting why the browser implementation doesn't follow the specification (well, perhaps because it is a draft).

Anyway, I've convinced myselft that the event paste is not capture by a drop down list, at this moment. Perhaps, in the future, when the specification is released.....

About you question over the reason of being trying to capture the event, it is because my customer wants to be able to paste a formatted list over a drop down list, and this action must provoke that the elements of the pasted list are options of the drop down list element. I cannot use a div over the element because the options must can be selected. At this moment, I'll have to use another element (text field, text area) to capture the paste event with the formatted list and accomplish the required functionality.

Well, thank you again for your interest


Best regards.
reply
    Bookmark Topic Watch Topic
  • New Topic