[Answer]-Django-how to implement javascript for the Save button in Html to help redirect to a new url

1👍

<input type="button" value="Edit" onclick="edit({{someobject.id}})"/>

<script>
function edit(id) {
    var c = confirm("Do you really want to edit the info?");
    if (c == true) {
           window.location = '/someurl/'+id
    }
}
</script>

0👍

Being a submit button makes no difference in the js confirmation dialog.The below code works for me.

<form action=/url method=post id=f>
...
<input type=submit value='blah'>
</form>

<script>
    $('input[type=submit]').click(function()
    {
        if (confirm('Sure?'))
        {
            $('#f').submit();
        }
        else
        {

        }
    });
</script>

And as for alignment,try using a table for aligning your buttons horizontally or vertically.

👤rjv

Leave a comment