#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    156
    Rep Power
    17

    Selecting a Radio Button Option - Problem


    Background:

    On a form in my page, I have a question with yes / no radio button options. When selecting yes, this then reveals an additional question (done through altering the css visibility of a div using js). Here's a snippet of my form:
    PHP Code:
    <form action="myAction.do">
    <
    table>
      <
    tr>
        <
    td>Additional Info Required?</td>
        <
    td>
          
    Yes<input type="radio" name="additionalInfo" value="yes">
          
    No<input type="radio" name="additionalInfo" value="no">
        </
    td>
      </
    tr>
      <
    tr>
        <
    td colspan="2">
          <
    div style="display: none">
            <
    table>
              <
    tr>
                <
    td>Further Information:</td>
                <
    td>
                  <
    input type="text" name="furtherInfo" />
                </
    td>
              </
    tr>
            </
    table>
          </
    div>
        </
    td>

    </
    form
    The response to this question is via a text field. In my DB, I only persist the furtherInfo field and derive whether the radio button should be set to yes or no based upon whether the furtherInfo is empty.

    Problem:

    The above works absolutely fine for new applications. My problem is for existing applications that customers choose to edit. I have validation on creating and editing new applications to ensure that the user selects one of the radio button options (yes or no). For the purposes of data migration, none of the existing applications will have this field set. I want users to be able to edit existing applications, but for validation to allow the user not to have to specify yes or no. The reasons for this is a little convoluted, but none the less, this is the requirement.

    I had proposed to solve this by creating a third hidden radio button as follows:

    PHP Code:
    <input type="radio" name="additionalInfo" 
           
    value="notspecified" style="display: none"
    Unfortunately, I can't see how I would be able to get existing applications to be set to this option as this field is not persisted in the DB (and I don't wish to store this field there). I could set the furtherInfo field in the DB to a specific value which the struts action interprets to set the additionalInfo to 'notspecified'. This however seems messy and also confusing in terms of the information displayed to the user.

    I would appreciate if anyone has encountered this type of problem before, to propose possible solutions.

    Thanks in advance,

    Mark

    Comments on this post

    • requinix disagrees : duplicate
    Last edited by markb_1984; November 3rd, 2009 at 05:13 PM.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2009
    Posts
    29
    Rep Power
    0
    Originally Posted by markb_1984
    Background:

    On a form in my page, I have a question with yes / no radio button options. When selecting yes, this then reveals an additional question (done through altering the css visibility of a div using js). Here's a snippet of my form:
    PHP Code:
    <form action="myAction.do">
    <
    table>
      <
    tr>
        <
    td>Additional Info Required?</td>
        <
    td>
          
    Yes<input type="radio" name="additionalInfo" value="yes">
          
    No<input type="radio" name="additionalInfo" value="no">
        </
    td>
      </
    tr>
      <
    tr>
        <
    td colspan="2">
          <
    div style="display: none">
            <
    table>
              <
    tr>
                <
    td>Further Information:</td>
                <
    td>
                  <
    input type="text" name="furtherInfo" />
                </
    td>
              </
    tr>
            </
    table>
          </
    div>
        </
    td>

    </
    form
    The response to this question is via a text field. In my DB, I only persist the furtherInfo field and derive whether the radio button should be set to yes or no based upon whether the furtherInfo is empty.

    Problem:

    The above works absolutely fine for new applications. My problem is for existing applications that customers choose to edit. I have validation on creating and editing new applications to ensure that the user selects one of the radio button options (yes or no). For the purposes of data migration, none of the existing applications will have this field set. I want users to be able to edit existing applications, but for validation to allow the user not to have to specify yes or no. The reasons for this is a little convoluted, but none the less, this is the requirement.

    I had proposed to solve this by creating a third hidden radio button as follows:

    PHP Code:
    <input type="radio" name="additionalInfo" 
           
    value="notspecified" style="display: none"
    Unfortunately, I can't see how I would be able to get existing applications to be set to this option as this field is not persisted in the DB (and I don't wish to store this field there). I could set the furtherInfo field in the DB to a specific value which the struts action interprets to set the additionalInfo to 'notspecified'. This however seems messy and also confusing in terms of the information displayed to the user.

    I would appreciate if anyone has encountered this type of problem before, to propose possible solutions.

    Thanks in advance,

    Mark
    Please read the sticky that says something like NEW USERS THIS IS NOT A JAVA SCRIPT FORUM? Ring a bell?! yeah well hopefully an admin will lock and boot this from this forum.

    Comments on this post

    • ishnid disagrees : Try at least reading the original post before being this rude. Better yet, try not to be this rude next time.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    156
    Rep Power
    17
    If you read my problem, this is not a javascript issue. My problem is that of architecture and persistence and retrieval of data. More specifically my problem concerns how the business layer is able to populate a form with minimally persisted data.

    My issue does concern html, but the only link to js is for toggling the visibility of a text field.

    Please do read carefully before posting such remarks.

    I would be most obliged if anyone could offer advice with regards to the above outlined problem.

    Thanks in advance.
  6. #4
  7. kill 9, $$;
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2001
    Location
    Shanghai, An tSín
    Posts
    6,878
    Rep Power
    3890
    When your user is being presented with the info to edit, can you not set a value for that radio button?

    I'm not clear on how older applications are different from new ones: is it because the ability to have this additional information is new? If so, can the radio button be set to "no" by default?

    It's possible I'm missing the point slightly.

IMN logo majestic logo threadwatch logo seochat tools logo