[Mapserver-users] Re: onSubmit - jBox

Richard Greenwood rich at greenwoodmap.com
Tue Feb 3 22:44:52 EST 2004


Steve McCrone wrote:
> Hello Richard,
> 
> I have just posted this question, but thought I would also ask you since you
> have done simiar to what I am trying to do
> Here's what I've got -
> 
> function setbox_handler(name, minx, miny, maxx, maxy, redraw) {
>   document.mapserv.imgbox.value = minx + " " + miny + " " + maxx + " " +
> maxy;
>   document.mapserv.imgxy.value = minx + " " + miny;
>   document.mapserv.submit();
>  }
> 
> function preSubmit(){
>     ...
> }
> 
> <form method="GET" action="[program]" name="mapserv" onSubmit="preSubmit()">
> 
> The setbox_handler function gets called when a "tool" is used, and
> therefore, the document appears to be submitted. However, the preSubmit()
> function does not get called. It only gets called when the user does a
> "refresh" (i.e.<input type="submit" value="Refresh/Query">)
> 
> Can't figure out why the document.mapserv.submit(); statement will not
> actually submit the form in order to have my preSubmit() function called  -
> strange.

I think this is a peculiarity of Javascript. The Javascript submit()
function simply submits the form "directly", it does not look at, or 
process any of the attributes in the <FORM> tag. So to process the 
preSubmit() function in setbox_handler() you need:
    if (preSubmit()) {
       document.mapserv.submit();
    }
assuming your preSubmit() function returns a boolean value, or if not 
simply :
    preSubmit();
    document.mapserv.submit();

Rich
-- 
Richard Greenwood
www.greenwoodmap.com




More information about the mapserver-users mailing list