Shoutbox

JavaScript help - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: JavaScript help (/showthread.php?tid=59887)

JavaScript help by lordy on 05-29-2006 at 12:12 AM

I'm trying to make a function that displays a confirm box when someone clicks on the 'submit' button of a form, then if they click ok it submits the form and if they click cancel it resets it. atm i have this:

code:
function submit_form(id) {
    var formid = getElem(id);
    if (confirm("blah")) {
    formid.submit();
    }
    else {
    formid.reset();
    }
}

But it doesn't display the confirm box at all :( can anyone help? :P
RE: JavaScript help by matty on 05-29-2006 at 12:50 AM

[/code]function deletePost(pid) {
    confirmReturn = confirm("Are you sure you want to delete this post?");
    if(confirmReturn == true) {
        window.location = "editpost.php?action=quickdelete&pid="+pid;
    }
}[/code]

taken from http://shoutbox.menthix.net/general.js


RE: JavaScript help by lordy on 05-29-2006 at 01:20 AM

hmm. i now have:

code:
function submitForm(id) {
    var formId = getElem(id);
    var confSub = confirm("Test");
    if(confSub == true) {
        formId.submit();
    }
    else {
        formId.reset();
    }
}

btw getElem() is:
code:
function getElem(id) {
    var divid = document.getElementById(id);
    return divid;
}
and I have:
code:
<form id="hostsu" method='POST'>
<<form here>>
<input type="button" onclick="submitForm('hostsu');" value="Submit">
Clicking the button just does nothing...
RE: JavaScript help by lordy on 05-29-2006 at 01:31 AM

ok nvrmind, it works fine :P

I had it looking for the wrong js file 8-)