Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Both the single double quote down below...

HTML
form class=""action="index.html">


and the double double quote below work?

HTML
form class=""action="index.html"">


Why is this the case?

Here is the full code.

<html>

<body style="text-align:center;">
				
	<h1>Enter Your Five Favorite Cities</h1>
	<form class=""action="index.html"">				
		<input type="text" name="favoriteCities[]" value="" /><br>
        <br>
		<input type="text" name="favoriteCities[]" value="" /><br>
        <br>
		<input type="text" name="favoriteCities[]" value="" /><br>
        <br>
		<input type="text" name="favoriteCities[]" value="" /><br>
        <br>
		<input type="text" name="favoriteCities[]" value="" /><br>
	<br>
        <button type="button" name="button" onclick="favoriteCities();reversefavoriteCities();">Submit</button>
   
    </form>
 
	<h2>Results</h2>
 
    <p id="output1"></p>
	<p id="output2"></p>

    
	<script type="text/javascript">
        var r = "";
        function favoriteCities() {
            var input = document.getElementsByName('favoriteCities[]');
 
            for (var i = 0; i < input.length; i++) {
                var a = input[i]; var uniqueNumber=i+1;
                r = r + "City #" + uniqueNumber + " is " + a.value + ("<br>");
            }
            document.getElementById("output1").innerHTML = r;
			}
    </script>
	
	<script type="text/javascript">
		function reversefavoriteCities() {
			var input = document.getElementsByName('favoriteCities[]');
			let i = input.length, r = '';
			while (i > 0) {
			r += `City #${i} is ${input[i-1].value} <br>`; i--;
			}
			document.getElementById("output2").innerHTML = r;
			}
	</script>
	
</body>
 
</html>


What I have tried:

Searched google about quotations.
Posted
Comments
Richard MacCutchan 4-Sep-22 3:21am    
That does not look correct; the class and action attributes are usually separate. Why did you write it that way?
Member 15627495 4-Sep-22 3:41am    
browser and Js engine are very powerful to handle bad code...
the case is about a partial code or a miswritten code will be display,
as sum up, It's "quirck code mode" by web browsers.

<form class="" action="another_file.htm">

// It's ok to have an empty value for the attribute 'class'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900