Results 1 to 3 of 3

Thread: Make input text unfillable if radio answer "N"

  1. #1
    Join Date
    Nov 2005
    Location
    Austin TX,US
    Posts
    71
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Make input text unfillable if radio answer "N"

    Hi,

    I'm working on a form and wondering if there's a script that can do the following.
    I have: Q1: radio inputs with 2 options : Yes and No
    If somebody clicks Yes, then they go to Q2: fill in some input text fields.
    If they click No, they'll skip 2 and go to Q3.

    My question is: can we do something with javascript & CSS so that when they click No in Q1, Q2 with input text fields become unfillable, hidden, or at least change colors...

    Thanks for help.

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Unfillable:

    Code:
    function makeUnfillable(){
    document.forms['formname'].elements['fieldname'].readonly = "true"
    }
    Hidden:

    Code:
    function makeHidden(){
    document.forms['formname'].elements['fieldname'].style.visiblity = "hidden"
    }
    Changing Colours:

    Code:
    function changeColor(){
    document.forms['formname'].elements['fieldname'].style.bgcolor="color"
    }
    I think...


    Untested.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Additionally, though, it should be noted that a value already in the box when it is made hidden/inactive may still be sent to the next page.

    You could also include field.value = ""; in the functions to be sure of that.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •