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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

submitting a form unconventionally

Status
Not open for further replies.

onressy

Programmer
Joined
Mar 7, 2006
Messages
421
Location
CA
I have the name of the submit button from this tag:
<input type="Submit" name="nextpagebtn" value="Next Page">

I have the form name from this tag:
<FORM METHOD="POST" NAME="MainForm" onSubmit="return ValidateSurvey( document.MainForm );" ACTION="preview.asp">

my issue is that the above tags are generated by the system, hence i cannot alter them/add to them in any way, cause the system automattically throw the tag in, so if i add the tag, i now have two form tags.

I would like to check some values in the code [ yes i can add some html code and javascript] so i added a form [with out the form tag] and the system took the tble a placed it between the form tag, since the system add a submit button tag that i cannot alter... how can i check the value of variable a1a before the user clicks the button and alert/return false; so that the form does not submit?

Thanks - hope this made sense...;)
 
basically something that states that if the sum of the rows [which is aa1] does not equal 100% then cancel the submit button - something along these lines:

if (aa1 != 100){document.MainForm.submit()==False;alert("all columns must resolve to 100%");document.MainForm.wsb29_4.focus();return false;}


 
Without seeing the rest of the Javascript code for your ValidateSurvey function, I recommend something like this:
Code:
if (aa1 != 100)
  {
  alert("all columns must resolve to 100%");
  document.MainForm.wsb29_4.focus();
  return false;
  }
return true;

Lee
 
thanks, on more thing i have 5 columns aa1 - aa5, how could it be incorporated into your script

Thanks again
 
something kinda like this:
for (i=1;i<6;i++) {
if (aa != 100)
{
alert("all columns must resolve to 100%");
document.MainForm.wsb29_4.focus();
return false;
}
return true;}
}
 
You need to realize that no one here can see your form or Javascript, so we have to go on the information you provide. You have provided little so far. We can't tell if aa1 is a total you've come up with or what, and your later posts make it sound like it might be the name of a form element. But who knows if it's a dropdown list, radio button array, text box, checkbox array, or something else?

Show the relevant code (not the whole page, just the stuff that your problem refers to) and you'll be able to get better help. Otherwise, everyone is flying blind but you, and you don't know the answer either.

Lee
 
Assuming that aa1 - aa5 are global variables, try this:

Code:
for (var loop=1; looop<6; loop++) {
	if (window['aa' + loop] != 100) {
		alert('All columns must resolve to 100%');
		document.forms['MainForm'].elements['wsb29_4'].focus();
		return (false);
	}
	return (true);
}

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top