Focal Point
SOLVED]javascript alert

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7827030876

August 24, 2015, 11:59 AM
Jay Potter
SOLVED]javascript alert
I am trying to add javascript to my submit button. If the user doesn't enter in selection criteria. It is suppose to give them an alert and not execute the submit. I get it to show the alarm, but it executes the submit. What am I missing?

  

//Begin function form1Submit_onclick
function form1Submit_onclick(ctrl) {
	e1 = document.getElementById("edit1");
	c1 = document.getElementById("combobox1");

	if (c1.value == '' && e1.value == ''){

		alert("Please enter in a value for a Product or a NDC!");
		return false;
   }else {
   	return true;
   }
   document.form1.submit();

}
//End function form1Submit_onclick


This message has been edited. Last edited by: Jay Potter,


WebFocus 8.1.5
iSeries/Windows
DB2/SQL/Access
Dev Studio
App Studio
Maintain
ReportCaster
August 24, 2015, 12:32 PM
Francis Mariani
Jay,

The form will submit because your document.form1.submit(); statement is outside the if statement. If you put it right after the else - I'm not sure what the return true; does, try replacing that with the submit statement.


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
August 24, 2015, 12:41 PM
Jay Potter
This is what I changed it to and it is still submitting.

 

//Begin function form1Submit_onclick
function form1Submit_onclick(ctrl) {
	e1 = document.getElementById("edit1");
	c1 = document.getElementById("combobox1");

	if (c1.value == '' && e1.value == ''){

		alert("Please enter in a value for a Product or a NDC!");
		return false;
   }else {
		document.form1.submit();
   }


}
//End function form1Submit_onclick
 



WebFocus 8.1.5
iSeries/Windows
DB2/SQL/Access
Dev Studio
App Studio
Maintain
ReportCaster
August 24, 2015, 01:03 PM
CoolGuy
Check this thread out:
http://stackoverflow.com/quest...from-being-submitted


8.2.02M (production), 8.2.02M (test), Windows 10, all outputs.
August 24, 2015, 01:44 PM
Jay Potter
Thank You for your suggestions. I had tried all those things before and they didn't work. So I rebuilt the form from scratch and I got it to work. I think there was a problem with the way the form was modified multiple times.

Thanks again


WebFocus 8.1.5
iSeries/Windows
DB2/SQL/Access
Dev Studio
App Studio
Maintain
ReportCaster
August 24, 2015, 05:57 PM
Waz
One thing you need to be aware of, is if the button is a submit button or not.

If it is, then the onclick needs to return a false/true, if it isn't then Jays, code will work.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

August 25, 2015, 10:15 AM
BarryS
Hi Jay

Create a new button and remove the value and add the IBI_btn-run to the class identifier. This will make the button look like the submit btn and then hide the original submit button.

If in App Studio then in the code for the new button use: IbComposer_triggerExecution(taskName, whichRequest) or in DevStudio use IbComposer_execute or just programmatically trigger the onclick event for the old submit button.

Thanks Barry


WebFOCUS 8103, Windows, App Studio
August 25, 2015, 11:30 AM
Jay Potter
Thank you for the information. I recreated the form from scratch and I is working for me.


WebFocus 8.1.5
iSeries/Windows
DB2/SQL/Access
Dev Studio
App Studio
Maintain
ReportCaster