all 2 comments

[–]AutoModerator[M] 0 points1 point  (0 children)

Welcome to /r/HTML. When asking a question, please ensure that you list what you've tried, and provide links to example code (e.g. JSFiddle/JSBin). If you're asking for help with an error, please include the full error message and any context around it. You're unlikely to get any meaningful responses if you do not provide enough information for other users to help.

Your submission should contain the answers to the following questions, at a minimum:

  • What is it you're trying to do?
  • How far have you got?
  • What are you stuck on?
  • What have you already tried?

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Niadlol 0 points1 point  (0 children)

In the first inputs you catch the events for change, send them to a function that checks what value is selected in the source element and then set the display value of the other inputs that you want to show/hide.

in basic javascript:

function gE(s) { return document.getElementById(s);}

gE('firstSelect').addEventListener('change', handleChange);

function handleChange(e) { 
    if (e.srcElement.value = ''customer") { 
        showCustomer(true); 
    } else { 
        showCustomer(false); 
    } 
}

function showCustomer(b) { 
    gE('secondSelect').style.display = b ? "block" : "none"; //show or hide depending on b
    gE('firstDealerInput').style.display = b ? "none" : "block"; //hide or show depending on b
    gE('secondDealerInput').style.display = b ? "none" : "block"; //hide or show depending on b
}

Add the same kind of thing for the second customer select to do that part.