Click to See Complete Forum and Search --> : validation problem


mili
07-10-2003, 05:43 PM
function ignoreRecord() {
document.forms[0].action="/Workflow?action=ErrorSaveToXML";
document.forms[0].method="post";
//hidden fields
var xmlName = document.forms[0].nm_xml_file_stored.value;

var selectedErrorRecord = '';
var ignore = '';
var e, f = document.forms;
var j, i, flen = f.length;

for (i=0; i<flen; i++) {
if (f[i].multipleaction != null) {

if (f[i].multipleaction.checked){
selectedErrorRecord += f[i].recId.value + ';';
alert(selectedErrorRecord);
ignore += f[i].ignoreRec.value + ';';
alert(ignore);
}
}
}
document.forms[0].recId.value = selectedErrorRecord;
document.forms[0].ignoreRec.value = ignore;
if(document.forms[0].ignoreRec.value = false)
{
document.forms[0].submit();
}
else
{
//if(document.forms[0].ignoreRec.value = true)
alert('Record is already Ignored');
return;
}
}

My Valiadtion in the above script fails.
If ignoreRec.value = false, I want to submit the form, else I want to raise an alert and stop the form from submission.
My code raises an alert even if ignoreRec.value = false.Please can some on tell me where I'm going wrong?
Thanks

Jona
07-10-2003, 07:08 PM
if(document.forms[0].ignoreRec.value = false)


Use two equals signs to compare values.

[J]ona

mili
07-10-2003, 07:17 PM
thanks jona. I figured out what the problem is.
I had to do document.forms[0].field.value == 'false;'
Like you said == was required and also the semicolon after false since I use that for concatenation.

thanks again
good night

Jona
07-10-2003, 07:25 PM
You're welcome. :)

[J]ona

mili
07-11-2003, 10:28 AM
Oops! Doesnt work the way I thought it should be.
Basically I'm submitting multiple records using a checkbox.I concatenate the selected recId's using ; in a variable called selectedErrorRecord and then assign my input hidden field to this concatenated varibale.For every record, I also have a input hidden field called ignoreRec.If the value of this field is false. I want to submit else I want to raise an error.
My code works for any one record.If I select multiple records containing false, it alerts the error instead of submitting.Please can some one help me with this pls?

function ignoreRecord() {
document.forms[0].action="/Workflow?action=ErrorSaveToXML";
document.forms[0].method="post";
//hidden fields
var xmlName = document.forms[0].nm_xml_file_stored.value;

var selectedErrorRecord = '';
var ignore = '';
var e, f = document.forms;
var j, i, flen = f.length;

for (i=0; i<flen; i++) {
if (f[i].multipleaction != null) {

if (f[i].multipleaction.checked){
selectedErrorRecord += f[i].recId.value + ';';
alert(selectedErrorRecord);
ignore += f[i].ignoreRec.value + ';';
alert(ignore);
}
}
}
document.forms[0].recId.value = selectedErrorRecord;
document.forms[0].ignoreRec.value = ignore;
if(document.forms[0].ignoreRec.value == 'false;')
{

document.forms[0].submit();
}
else
{
//if(document.forms[0].ignoreRec.value == 'true;')

alert("Record " + selectedErrorRecord + " is already Ignored" );


return;
}
}

Jona
07-11-2003, 12:20 PM
Because you are treating it as a string rather than a boolean value, you have this:


if(document.forms[0].ignoreRec.value == 'false;')


However, this would only work if you had selected one checkbox that was equal to "false;." Instead, you should try using something like this:


if(document.forms[0].ignoreRec.value.indexOf("false;") != -1)


[J]ona

mili
07-11-2003, 01:36 PM
works like a charm :)

you are the best!

thanks

Jona
07-11-2003, 01:38 PM
You're welcome. :)

[J]ona