Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

HTML/Javascript questions: A. Provide the object reference to the third web form

ID: 3701956 • Letter: H

Question

HTML/Javascript questions:

A. Provide the object reference to the third web form in the page.

B. Provide code to change the value of the input box with the ID “country” to “Mexico”.

C. Provide code to retrieve the value of the selected option in the selection list with the ID “state”, storing the value in the variable stateName.

D. Provide code to run the calcShipping() function when the value of the state field in the shoppingCart form is changed.

E. Provide the regular expression to match every occurrence of the word “the”.

Explanation / Answer

Solution A.
<form name="form1">
...
...
</form>
<form name="form2">
...
...
</form>
<form name="form3">
...
...
</form>
var object = document.forms["form3"];

Solution B.
<script>
$(document).ready(function(){
$("p").click(function(){
$("#country").val("Mexico");
});
});
</script>
<p>City: <input type="text" id="country" value="Montreal" name="user"></p>/*you can also make a button and change the above code accordingly*/

Solution C.

<select id="state" name="State">
<option value=""> - Select - </option>
<option value="Victoria">Victoria</option>
<option value="Queensland">Queensland</option>
...
<option value="Tasmania">Tasmania</option>
</select>

<button type="button">State</button>
<p id="retrieve"></p>
<script>
function myFunction() {
var stateName = document.getElementById("state").value;
document.getElementById("retrieve").innerHTML = stateName;
}
</script>