I am having trouble getting this to work. I have a form which when the Go button is clicked, calls a function; code for the form & the script listed below:

    function RunSelectedReport(reportChoice) {
      alert("reportChoice: " + reportChoice);
      if ( reportChoice === "AllCalls" ) {
        alert("All Calls");
      } else if ( reportChoice === "DaveCalls" ) {
        alert("Dave's Calls");

    <form name="daveSvcCallReports" action="@VAR_SECURE_HTTP_@@VAR_FORM_ACTION_URL_@" method="post">
      <input type="radio" name="reportChoice" value="AllCalls">All Calls</input>
      <input type="radio" name="reportChoice" value="DaveCalls">Dave's Calls</input>
      <input type="button" value="Go" onclick="RunSelectedReport(document.daveSvcCallReports.reportChoice.value);"></input>

My first alert I placed inside the function, for debugging, returns "Undefined" for the value of reportChoice. However, if I change the line within the form from <input type="button" value="Go" onclick="RunSelectedReport(document.daveSvcCallReports.reportChoice.value);"></input> to <input type="button" value="Go" onclick="RunSelectedReport(1);"></input>, then my function returns a value of 1 for reportChoice. I'm just not seeing what I have wrong with my code, thanks for any help.

6 Years
Discussion Span
Last Post by spowel4
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.