Kalyanam Rajashree Kalyanam Rajashree - 12 days ago 5
HTML Question

Button in javascript which in turn pops up a button

I want to have a button in javascript which in turn pops up a button on clicking which I get to call a function. I am referring to this. In this you can see a drop down menu popping up by clicking on a button. I want a button instead. Or this menu is fine but I want to have them as buttons. Any idea how to go about this ?

The code(html and javascript) is

<div id="dialog" title="Basic dialog">
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>
</div>
<input type="button" id="target" value="click"/>


$( "#dialog" ).hide();
$( "#target" ).click(function() {
$( "#dialog" ).show();
$( "#dialog" ).dialog();
});

Answer

What about this:

$( "#dialog" ).hide();
$( "#target" ).click(function() {
      $( "#dialog" ).show();
    $( "#dialog" ).dialog();
});
$( "#dialogButton" ).click(function() {
    doStuff();
});

function doStuff() {
 window.open('https://www.youtube.com/watch?v=kfVsfOSbJY0', '_blank');
}
<link href="http://code.jquery.com/ui/1.9.1/themes/smoothness/jquery-ui.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script
  src="http://code.jquery.com/ui/1.12.0/jquery-ui.min.js"
  integrity="sha256-eGE6blurk5sHj+rmkfsGYeKyZx3M4bG+ZlFyA7Kns7E="
  crossorigin="anonymous"></script>

<div id="dialog" title="Basic dialog">
<input type="button" id="dialogButton" value="wut wut?"/>
</div>
<input type="button" id="target" value="click"/>