My function:
Code: Select all
//Define a function to alert the user of cross entered details if necessary
function cross_entry() {
//If the user has chosen to use an existing make but has entered something in the new make box *OR*
//If the user has chosen to add a new make but has chosen an existing make from the selection box
if ((document.getElementById('makechoice').value == 'existing' && document.getElementById('newmake').value != '') ||
(document.getElementById('makechoice').value == 'addnew' && document.getElementById('make').value != 'none')) {
//Show a confirmation alert
return confirm("You have cross-entered make details.\n\nAre you sure you want to use the details corresponding to the radio button choice?");
}
}Code: Select all
<form action="<?php echo basename(__FILE__); ?>" method="post" enctype="multipart/form-data" onSubmit="javascript: cross_entry();">I though this would work because the below code only submits the form if the user clicks OK, not when the user clicks Cancel:
Code: Select all
<form name="editrecord" action="' . basename(__FILE__) . '" method="post" onsubmit="return confirm(\'Are you sure?\');">Thanks