Display dialog box when right-clicking

Asked

Viewed 783 times

0

I have a form with multiple fields and I want to put the option of the user to insert a comment in the field value.

Example:

<form>
  <input type='text' id='campo'>
  <input type='hidden' id='comentario'>
  <submit>
</form>

What I want to do is right-click the input[id=campo]it shows a balloon so I put a text and this text will stay on value of my field input[id=comentario].

Can someone give me an example of how to do this?

1 answer

1


I made minor modifications to Jsfiddle of the commented response.

Test here

HTML:

<div class="content">    
    <input type="text" placeholder="Clique aqui com o botão direito para comentar" />   
    <div id="comentario" style="display:none">
        <form>
            <textarea></textarea>
            <button type="submit">Enviar</button>
        </form>
    </div>    
</div>

Javascript:

 $("div.content").oncontextmenu = function() {return false;};

  $('input[type=text]').mousedown(function(e){ 
    e.preventDefault();
    if( e.button == 2 ) { 
      $('#comentario').show();
    } 
    return false;
  }); 
  • It’s almost that, I just need to put it together with another project that I have, because I want to make this box appear inside a balloon and at the time I click off the balloon and there’s a marker in the box. And then Submit is in the two input.

  • When I right click it still opens the default dialog box, have to make it disappear?

  • the following is an all-test code: http://codepen.io/MarciusMcflay/pen/YWKEJe

Browser other questions tagged

You are not signed in. Login or sign up in order to post.