Results 1 to 2 of 2

Thread: hide/show fields (not check boxes)

  1. #1
    Join Date
    Sep 2006

    hide/show fields (not check boxes)

    I am building a form with Javascript that will build a part number and price. I need to set it up so that certain options only show for specific sizes. For example: if (size<5) hide these 3 options. The productsize is an option select but I also need to expand it to read if (productsize<5 || custom<5) then hide the div id"opt".

    I've tried this:
    function showopt(){
    var sizeIndex=partform.size.selectedIndex
    if (partform.size.options[sizeIndex].value<5) {
    } else {

    Where opt is the id for a <DIV> but it is not working. (I added onchange="showopt();" for the field id size)

    Any ideas where I'm going wrong?

  2. #2
    Join Date
    Sep 2006
    I found my answer, see below:
    function hideopts(){
    var sizeIndex=partform.size.selectedIndex
    if(partform.size.value>=5 || partform.custom.value>=5){
    document.getElementById("opt").style.display = "block";
    document.getElementById("opt").style.visibility = "visible";
    else {
    document.getElementById("opt").style.display = "none";
    document.getElementById("opt").style.visibility = "hidden";}

    "opt" is the DIV id around the fields I want to hide. Partform is the form name, size and custom are the form fields where the content will decide if the fields in the <div> will show or hide. (size is a select drop down, custom is a text field)

    Hope this helps someone else.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Recent Articles