Set radio button from textbox inputhelp needed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alan Badia

    Set radio button from textbox inputhelp needed

    I have a form where I need to set the radio button according to the
    user's input. For example, if the user enters 21 or greater, I need the
    adult radio button to be ticked. If the user enters 0-20, I need the
    minor radio button to be ticked. Here's my code and I'm sure it's not
    right. Please help.

    <script language="JavaS cript">
    <!--
    function AdultCheck() {
    if (document.form1 .AGE.value >= 21) {
    document.form1. adult.value.che cked = true
    } else {
    document.form1. minor.value.che cked = true
    }
    }
    //-->
    </script>



    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
  • Michael Winter

    #2
    Re: Set radio button from textbox inputhelp needed

    "Alan Badia" wrote on 11/11/2003:
    [color=blue]
    > I have a form where I need to set the radio button according to the
    > user's input. For example, if the user enters 21 or greater, I need[/color]
    the[color=blue]
    > adult radio button to be ticked. If the user enters 0-20, I need the
    > minor radio button to be ticked. Here's my code and I'm sure it's[/color]
    not[color=blue]
    > right. Please help.
    >
    > <script language="JavaS cript">
    > <!--
    > function AdultCheck() {
    > if (document.form1 .AGE.value >= 21) {
    > document.form1. adult.value.che cked = true
    > } else {
    > document.form1. minor.value.che cked = true
    > }
    > }
    > //-->
    > </script>[/color]

    Remove '.value' from adult and minor, so they read:

    document.form1. adult.checked = true;

    Note that I ended the statement with a semi-colon. All statements
    should end with one, so add one after each assignment operation.

    You should also consider using something other than 'form1'. You
    should always use meaningful names for identifiers.

    Mike

    --
    Michael Winter
    M.Winter@[no-spam]blueyonder.co.u k (remove [no-spam] to reply)


    Comment

    Working...