Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can't get submit button to work properly

Status
Not open for further replies.

Ngai88

Programmer
Sep 8, 2004
56
US
Hello,
I have a jsp page that has multi radio buttons and select boxes, and when the user finish selecting the choices, he will push the 'submit' button to complete the process.
Right now, if you press the 'submit' button it goes to an Exception Error.

Exception: com.EGTV.controller.RosterController: while formatting strFIdnullstrPersonId: nullstrAgencyId: nulljava.lang.NumberFormatException: null

I have been trying to get this javascript to work, but still it goes back to the error message wheather I only select only one choice or select none when I hit 'submit' .
Can you tell me where I have messed up?

Thanks,
Ngai

below is my code:
==========================================================
function formCheck() {
var error = "Error(s):\n\n";
var shift = document.Schedule.Shift.value;
var prisup = document.Schedule.PriSup.value;
var func = document.Schedule.FId.value;
var agency = document.forms["Schedule"].Agency;
var agencyVal = agency.options[agency.selectedIndex].value;
var person = document.forms["Schedule"].Person;
var personVal = person.options[person.selectedIndex].value;

if (error != "Error(s):\n\n") {
alert(Please complete form before submitting);
return false;
}
else if (shift == null) {
error += "Please complete form before submitting";
}
else if (prisup == null) {

error += "Please complete form before submitting";
}
else if (func == null) {

error += "Please complete form before submitting";
}
else if (agency == null) {

error += "Please complete form before submitting";
}
else if (agencyVal == null) {

error += "Please complete form before submitting";
}
else if (person == null) {

error += "Please complete form before submitting";
}
else if (personVal == null) {

error += "Please complete form before submitting";
}
}


<form name="Schedule" method="post" onSubmit="return formCheck()" action="<%= webappContextPath %>/Roster.do?><expresso:TransitionParamsTag name='UpdateSchedule'/>">
 
alert(Please complete form before submitting); doesn't have quotes around the string and is probably causing an error. Also, the values of text boxes are always strings, not "null". You should check for an empty string. Select boxes don't return null either.


Adam
 
adam,
I have made some progress to the 'submit' button, it is not showing the error message anymore. But my questions is this...
Looking at the vars , I want to every time I select a choice, be it radio button or from select box, I want the selected choice to stay selected and then the next error will just tell me the next to select if not selected. How do I do that?
Also I do not seem to get the error message out from the javascript at all.
Right now what I have below is my debugging it, so the alert will come out like this ..

First alert shows '[object]' -- > I clicked OK then it goes to the next alert 'form:undefined' --> I clicked OK then it goes to the next alert 'Error(s);--> I clicked OK then it goes to the next alert 'undefined' .

Any help is much appreciated.
Ngai


The following is the updated code...
=====================================================
function verifyForm(form) {
alert(form);
alert("form: " + form.Shift.value);



var error = "Error(s):\n\n";
alert(error);
var shift = document.Schedule.Shift.value;
alert(shift);
var prisup = document.Schedule.PriSup.value;
var func = document.Schedule.FId.value;
var agency = document.forms["Schedule"].Agency;
var agencyVal = agency.options[agency.selectedIndex].value;

var person = document.forms["Schedule"].Person;
var personVal = person.options[person.selectedIndex].value;


if (shift == "") {
alert(error);
error += "Please select shift before submitting.\n";
}

if (prisup == "") {
alert(error);
error += "Please select Priority before submitting.\n";
}
if (func == "") {
alert(error);
error += "Please select function before submitting.\n";
}
if (agencyVal == "") {
alert(error);
error += "Please select Agency before submitting.\n";
}
if (personVal == "") {
alert(error);
error += "Please select Person before submitting.\n";
}

if (error != "Error(s):\n\n") {
alert(error);
return false;
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top