Don't use shorthand if you're not comfortable with JavaScript, it'll only trip you up further. Here's a revised fiddle that displays question one properly when 355 is entered into the serial number box.
$(document).ready(function () {
$("#cntnt01fbrp__70").keyup(function () {
$("#question-1").css("display", function() {
if ($('#cntnt01fbrp__70').val() === "355" && $('#fbrp__119').val()[0] === "2") {
console.log('worked');
return "block";
} else {
return "none";
}
});
});
});
Edit: As for your other questions, can you clarify a practical example of what you want to accomplish? What you described seems feasible, you simply need to do the string manipulation after getting both values, and adjust the conditional statements.
Edit 2: Modified to demonstrate additional conditions.
Edit 3: Rechecked and Rick was correct, removed those parts from my answer.
If you want to look for multiple values being selected, you'd have to check if the values are in the array, here's a solution for that which will return either true or false.
function isInArray(value, array) {
return array.indexOf(value) > -1;
}
You'd use it like so:
var selectedNumbers = $('#fbrp__119').val();
isInArray("2", selectedNumbers); //returns true if 2 is selected in the array.
Make sure you use quotation marks, as the array will return the values as strings.
Then use that boolean value to do whatever you'd like, you can check to see if 2 and 3 are in the array for instance by using that function twice, not the best execution, but just an example that it's possible.
As for multiple numbers in the input field, you're better off creating multiple input fields for different serial numbers, or creating an array from the values, and asking users to separate the values by a comma or space, and checking if the desired serial number is in the array as one part of your if statement condition. You can add as many &&
operators as you need to.