HOTSPOT
You review a web form that contains the following markup and code:
You need to ascertain how the webpage responds when it loads and how it reacts to user actions.
For each statement in the table, select Yes if the code segment above causes the page to behave as
described. Select No if it does not. Make only one selection in each column.
Could anyone explain this please?
When the page loads it’s not setting a color.
First time you click the textbox and the value equals nothing or null value === ”/null, the textbox will indeed showup in yellow. However if you alredy have a value in the textbox it will go into the else statement and therefore show white color so the anser of the second question is NO it’s dosent change to yellow each time..
And the third is ofc YES as explained above.
Since the third question specifies that the text box contains a value, but the second question does not, I believe the text box is assumed to be blank in question #2.
Therefore, I believe Microsoft is expecting a “Yes” for the second question:
No
Yes
Yes
For the first one: both check1 and check2 are not triggered when the page loads.So the background of text boxes are not yellow.
For the second one: the background color changes to yellow only when a text box contains nothing. In other word, if a text box has a value, the background color still keep white when it receives the focus.
For the last one: the reason is similar to the above one . onblur=”check1(this)” is called when the text box loses focus. Because of ” currentTextBox.Style.Background=’#ffffff’ “,the background color changes to white.
Another poorly written test question…
I have another point of view:
Javascript code is in the head tag. Which means the code won’t do what we want it to do (it runs before input fields are even created). In that case, all answers should be “No” because the input fields stay white no matter what.
However, I would agree with the answers (No, No, Yes) if the javascript code was written in the end of body tag.
But there is still one thing that bothers me. The statment says “…the text box CHANGES to white EACH TIME the text box loses the focus.” That is simply not true if you consider that when you click on and out of the input 2+ times (and something is written in it), the input doesn’t CHANGE to white but it stays white until you delete whatever is in the box.
Overall, I would agree with Al. Very poorly written question.
Hmm, correction: it does work in the head tag.