SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Jan 2006
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Radio buttons using AJAX always giving the same value

    I am using this code using AJAX. The probelm is no matter what choice is selected I always get the result grade=5. Can anyone help me with why this is the case? Thanks, Steven.


    <form>
    <li><input type="radio" id="grade" name="grade" value="5" accesskey="5">Great</li>
    <li><input type="radio" id="grade" name="grade" value="4" accesskey="4">Good</li>
    <li><input type="radio" id="grade" name="grade" value="3" accesskey="3">OK</li>
    <li><input type="radio" id="grade" name="grade" value="2" accesskey="2">Poor</li>
    <li><input type="radio" id="grade" name="grade" value="1" accesskey="1">Oh, oh</li>
    <li><input type="radio" id="grade" name="grade" value="0" accesskey="0">What is this?</li>
    <li><input value="Study now"
    type="button"
    onClick="getNewTotals();" >
    </li>
    </form>

    -------------------------------------

    Now that a grade is entered it should be picked up by this text:

    function createQueryString() {
    var grade= document.getElementById("grade").value;
    var queryString = "grade=" +grade;
    return queryString;
    }

    -------------------------------------

    function getNewTotals() {
    var url = "getUpdatedSales.php";
    url = url + "?dummy=" + new Date().getTime();
    var queryString= createQueryString();
    request.open("POST", url, true);
    request.onreadystatechange = updatePage;
    request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    request.send(queryString);
    }

    -------------------------------------

    Why do I always get a result of grade=5?
    Last edited by stevenodonnell; Aug 1, 2006 at 20:37.


Bookmarks

Posting Permissions

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