J
John Kiernan
Hey JavaScript gurus...
I'm going to try this again. I haven't gotten as much help as I have advice
on style<grin>. I appreciate (having programmed in other languages for
quite a while) that everyone has their own opinion on HOW things should be
done. However, if it does not comes AFTER helping me figure out my problem,
please... (fill in your own polite way to say 'save the bandwidth').
I have code in a MouseUp of my save button (yes, technically it should go
into the 'OnSubmit()' of the form, but I don't want to do that, because I'm
already hacking one pre-packaged class (in VFP) and I don't want to be
hacking a second). There is NO "OnSubmit" on the form itself (to pre-answer
a question).
On everything else in the JavaScript function I'm talking about, if I trap
for an input error, I return a 'false' and the form doesn't submit. If I
return a 'true', the Form submits just fine.
However, on the last part of the routine utilizes a 'Confirm()' -- within an
IF statement. As per a hint from someone here, I changed it from utilizing
a variable to simply returning a true or false. However, it doesn't work --
in the same way the variable didn't work. If I return a false, the form
doesn't submit, but even if I return a true, the form doesn't submit.
Using deductive reasoning in that I have the Confirm() within an IF
statement (and it's the only thing within it) and the whole thing works if I
don't enter the IF and it DOESN"T work if I do, I think I can narrow the
problem down to the Confirm().
I would simply put in a hard coded document.form.submit(), except that
doesn't work with the back end VFP stuff I have interpreting the return form
variables.
Can anyone else duoplicate this or help!?!?
I can't imagine someone else sometime hasn't put in a confirm() in this way?
Could it be? Code pasted in below...
Lost in Santa Monica.... (HELLLPPPP!!!)
-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends
function cliservsave() {
lvIsnew = document.getElementById('isnew');
lvIsnewV = lvIsnew.value
lvRepf = document.getElementById('repfreq');
lvRepfV = lvRepf.value;
lvNotes = document.getElementById('NOTES');
lvNVal = lvNotes.value;
lvDue = document.getElementById('duedate');
lvDueV = lvDue.value;
lvNotComp = document.getElementById('NOTCOMP');
lvNCVal = lvNotComp.checked;
if (lvNVal == "" && lvNCVal == true) {
alert("If Not Completed, Notes MUST be entered.");
return false;
}
lvDescrip = document.getElementById('DESCRIP');
lvDVal = lvDescrip.value;
if (lvDVal == "") {
alert("Description Cannot be Blank.");
return false;
}
if (lvNCVal == true && (lvDueV !== "" && lvDueV !== "01/01/00") ) {
alert("If Not Completed, Due Date must be Blank.");
return false;
}
if (lvIsnewV == "true" && lvRepfV !== "None") {
return confirm("Are you sure you want to generate multiple records?")
}
return true;
}
I'm going to try this again. I haven't gotten as much help as I have advice
on style<grin>. I appreciate (having programmed in other languages for
quite a while) that everyone has their own opinion on HOW things should be
done. However, if it does not comes AFTER helping me figure out my problem,
please... (fill in your own polite way to say 'save the bandwidth').
I have code in a MouseUp of my save button (yes, technically it should go
into the 'OnSubmit()' of the form, but I don't want to do that, because I'm
already hacking one pre-packaged class (in VFP) and I don't want to be
hacking a second). There is NO "OnSubmit" on the form itself (to pre-answer
a question).
On everything else in the JavaScript function I'm talking about, if I trap
for an input error, I return a 'false' and the form doesn't submit. If I
return a 'true', the Form submits just fine.
However, on the last part of the routine utilizes a 'Confirm()' -- within an
IF statement. As per a hint from someone here, I changed it from utilizing
a variable to simply returning a true or false. However, it doesn't work --
in the same way the variable didn't work. If I return a false, the form
doesn't submit, but even if I return a true, the form doesn't submit.
Using deductive reasoning in that I have the Confirm() within an IF
statement (and it's the only thing within it) and the whole thing works if I
don't enter the IF and it DOESN"T work if I do, I think I can narrow the
problem down to the Confirm().
I would simply put in a hard coded document.form.submit(), except that
doesn't work with the back end VFP stuff I have interpreting the return form
variables.
Can anyone else duoplicate this or help!?!?
I can't imagine someone else sometime hasn't put in a confirm() in this way?
Could it be? Code pasted in below...
Lost in Santa Monica.... (HELLLPPPP!!!)
-- John Kiernan, KierPro Associates
Custom VFP/Accounting Programming
and Web interfaces
VFP and/or SQL back ends
function cliservsave() {
lvIsnew = document.getElementById('isnew');
lvIsnewV = lvIsnew.value
lvRepf = document.getElementById('repfreq');
lvRepfV = lvRepf.value;
lvNotes = document.getElementById('NOTES');
lvNVal = lvNotes.value;
lvDue = document.getElementById('duedate');
lvDueV = lvDue.value;
lvNotComp = document.getElementById('NOTCOMP');
lvNCVal = lvNotComp.checked;
if (lvNVal == "" && lvNCVal == true) {
alert("If Not Completed, Notes MUST be entered.");
return false;
}
lvDescrip = document.getElementById('DESCRIP');
lvDVal = lvDescrip.value;
if (lvDVal == "") {
alert("Description Cannot be Blank.");
return false;
}
if (lvNCVal == true && (lvDueV !== "" && lvDueV !== "01/01/00") ) {
alert("If Not Completed, Due Date must be Blank.");
return false;
}
if (lvIsnewV == "true" && lvRepfV !== "None") {
return confirm("Are you sure you want to generate multiple records?")
}
return true;
}