#1
  1. Web Developer
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2001
    Location
    Pennsylvania
    Posts
    171
    Rep Power
    0

    JavaScript functions & ASP forms


    Ok, I am puzzled. I am trying to assign the value of a selected radio button to a JavaScript variable, but it keeps giving me undefined. I think the problem may be linked to the JavaScript being hard coded, and the form being dynamically generated, it's the only thing I can think of that may be causing this:

    Code:
    function doAction(a) {
      var url = "editTest.asp"
      var sessionID = document.editTest.sessionID.value
      if (a == 1) {
        url = url + "?action=edit&session="+sessionID
      } else {
      ...
      }
      var newWin = window.open(url)
    }
    I cut the code down to make it a little shorter and easier to read, but you should get the general drift. For those of you that may want to see the ASP that is generating the form, here:

    Code:
    <form name="editTest">
    ...
    <%
      ...
      Response.Write("<input type=""radio"" name=""sessionID"" value="""&myRecordset(0)&""" /></td>")
      ...
    %>
    myRecordset(0) does contain the correct value (as noticed by view source). Any suggestions?
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2001
    Posts
    765
    Rep Power
    13
    function doAction(a) {
    var sessionID, url = "editTest.asp";
    var el, i = 0, radgrp = document.editTest.sessionID;
    while (el = radgrp[i++]) if (el.checked) sessionID = el.value;
    if (a == 1) {
    url += "?action=edit&session="+sessionID

IMN logo majestic logo threadwatch logo seochat tools logo