Program stopping after javascript is executed

Results 1 to 2 of 2

Thread: Program stopping after javascript is executed

  1. #1
    Join Date
    Dec 1969

    Default Program stopping after javascript is executed

    I have the following HTML<BR><BR>&#060;button type="submit" id=button1 name=button1 onClick="return Val(theForm);document.theForm.action=&#039;../Gareths AJP mod/caseMangReview3.asp&#039;;window.close();"&#062;&# 060;img src="../test/images/yes.gif" alt="Save"&#062;&#060;/button&#062;<BR><BR>and javascript<BR><BR>function Val(theForm)<BR>{<BR> //alert(theForm);<BR> //alert(theForm.YearTo[theForm.YearTo.selectedIndex].value);<BR> varDay = theForm.DayTo[theForm.DayTo.selectedIndex].value<BR> varMonth = theForm.MonthTo[theForm.MonthTo.selectedIndex].value<BR> varYear = theForm.YearTo[theForm.YearTo.selectedIndex].value<BR> varDateTo = varYear + varMonth + varDay<BR> return (theForm);<BR>}<BR><BR>The javascript is executed and working fine but the program dies after the javascript is finished??<BR><BR>It doesn&#039;t execute the rest of code in the onClick event.<BR><BR>Any ideas why this is happening

  2. #2
    Join Date
    Dec 1969

    Default The clue here is the "return"... your onClick event handler. A "return" command does just that - it returns execution back to whatever called it, which is the browser in this case. Any commands after the "return" are never executed.<BR><BR>Depending on what you want to achieve, you need to execute the commands before you call the function, or call the function, store its return value in a variable, then execute the other commands and then return the value you stored in the variable.<BR><BR>Oliver.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts