简体   繁体   中英

javascript alert box with radio buttons

I want to create an alert box with 3 radio buttons in it. It should be like

'Replace' 'Save' 'Merge'

along with OK and Cancel buttons. Any idea how to achieve this?

There is no default javascript box that does this, you have confirm() , prompt and alert available and that's it.

There are however widgetsets/libraries that give you this option. Try Ext JS for example

To add to what WoLpH said, you specifically want a modal overlay that can be called programmatically similar to an alert box. Give jQuery UI or YUI a try.

You can use javascript to create modal dialog box with the controls you would like to show. You can customize the look & get rid of the default grey dialog boxes, it's really cool. Check the link below.

Javascript modal dialog sample

use the input tag to generate radio buttons

<input type="radio" name="button_1">Replace</input>

and div tag to generate you okay and cancel buttons

<div id="cancel">Cancel</div>

and have the onclick functions of your div's be a javascript call which pulls the data out of the radio buttons.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM