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:

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

    <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>
    </form>

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.

Actually that did help, thanks!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.