Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple inputs in a Bootbox

How can I have 2 inputs instead of just one in Bootstrap's Bootbox?

I need to receive 2 values in a modal dialog.

like image 667
kambi Avatar asked Sep 06 '25 16:09

kambi


1 Answers

Actually, there is a simpler way which doesn't require you to modify bootbox code.

The string you pass at the bootbox creation doesn't have to be only text: it can also be html code. That means you can include pretty much everything in the box.

To put a custom form in a bootbox, you can then create it as follow :

bootbox.confirm("<form id='infos' action=''>\
    First name:<input type='text' name='first_name' /><br/>\
    Last name:<input type='text' name='last_name' />\
    </form>", function(result) {
        if(result)
            $('#infos').submit();
});
like image 154
haradwaith Avatar answered Sep 09 '25 07:09

haradwaith