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.

Recommended Answers

Accessing the value for a set of radio buttons is not that straight forward. document.form_name.radio_name.value does not work. (Both Nescape and Internet Explorer return "undefined" as value).


i'm new to javascript but …

Jump to Post

All 2 Replies

Actually that did help, thanks!

Be a part of the DaniWeb community

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