JS realizes the second-level linkage of the drop-down frame

When doing projects, an issue of adding issues, options, and answers, the topic type is divided into two types, judgment questions, and multi-selection questions, and you need to add a secondary linkage function, ie When the subject is the selected question, the correct option’s drop-down box is A, B, C, D. If the subject is the judgment question, the correct option is correct, error, if the subject type is more The correct answer is the text box that can enter the answer type. The effect is in the text.

HTML page is as follows:

  // via the Fn () function to change the answer Box status 
Decision Multi-selection Correct option
/ / Write a drop-down frame here, when the subject is multi-selected, use JS to hide the pull-down box, the Input box is displayed
The following is the JS portion:
// When the page is loaded, the init function is executed, so that the text box of the correct answer of multiple questions hides init (); "init () {$ (" # answertrue1 ") .hide ();} // topic type and answer selection 2 secondary linkage function fn () {var type = document.GtelementByID (" type "); var t = type.value; var answer = document.getlementbyID ("ANSWERTRUE2"); Switch (T) {// Judgment is a choice question or judgment, then change the contents of the drop-down box Case "Select Questions": answer.innerhtml = "
a
B

D

“; $ (” # answertrue1 “). Hide (); $ (” # answertrue2 “). Show (); break; case” judgment question “: answer.innerhtml =”
correct
 Error  "; $ (" # answertrue1 "). hide (); $ (" # answertrue2 "). show (); break; default : $ ("# answertrue1"). Show (); $ ("# answertrue2"). hide ();}};    The achievement is as follows:        The above is all the content of this article, I hope to help everyone's learning, I hope everyone supports Tumi Cloud.                      
© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment