Submit Image button executes file twice

stingray70m

New Member
I'm having a problem with all pages that contain an image submit button.
When the "fcheckout" button is selected it executes "JY200VALIDATE3.r".
"JY200VALIDATE3.r" is then suppose to load "JY200.r" but what happens is it executes "JY200VALIDATE3.r" twice and then loads "JY200.r".

<html>
<SCRIPT language="JavaScript">

function checkoutPO( )
{
document.POSENT.style.cursor = "wait";
document.POSENT.CHGPO.disabled=true;
document.POSENT.buttonFindOrders.disabled=true;
document.POSENT.action = 'JY200VALIDATE3.r&`{&urlStateInfo}`';
document.POSENT.submit();
}
return true;
}
</SCRIPT>

<form method="post" name="POSENT">
<script language="speedscript">
{&OUT} '<input name="fcheckout" ' skip.
{&OUT} 'type="image"' skip.
{&OUT} 'id="fcheckout" ' skip.
{&OUT} 'src="/images/orders/L1.jpg" alt="Checkout" ' skip.
{&OUT} 'onClick="checkoutPO();">' skip.
</script>
</form>
</html>




/*------------------------------------------------------------------------
File: JY200VALIDATE3.P
Author: mea
Description: COPY TABLE OF ORDER DETAILS
------------------------------------------------------------------------*/

{src/web/method/wrap-cgi.i}
{ttg/ttgdefs.i}
&GLOBAL-DEFINE web-file TTGWEB
def var v-error as char no-undo.
def var v-po as char format "x(40)" no-undo.

v-po = trim(get-value("HIDDENPO")).

if trim(v-po) = "" then
set-user-field("JY200ERROR","PO ERROR").
end.
run run-web-object in web-utilities-hdl("JY200.r&`{&urlStateInfo}`").

return.
/************** END OF JY200VALIDATE ********/



I haven't included all the code as it happens when no relevant code is executed.
I'm relatively new so my method of running progress code which runs or generates an html page may be not the best.
Does anyone have any ideas?

Thanks
Mark
 
Hi Mark,

You don't need the submit() in your checkoutPO function as returning true in an onclick function means that the form is automatically submitted as this is the default behaviour for an image button.

Try either taking out submit() or returning false from the function instead of true.

Lee
 
I removed the submit() and left the .action above it and it worked!

Do you know why it works once with a submit button, type=button(not image)?

Thanks!!!
 
Back
Top