top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Unexpected Javascript error

+4 votes
421 views

Getting Exception parsing document error in for (var i = 0; i < Memoryval.length; i++) line.

Can anybody help?

Below is the code.

$(".rad").click(function () {
     var Memoryval = ["Fixed"];
     var CPU = ["Fixed", "Utilization", "OwnBorrow", "Custom", "Conditional"];
     var sel = document.getElementById('ddltype');
     sel.innerHTML = "";
     if (this.value == "MEMORY") {
         for (var i = 0; i < Memoryval.length; i++) {
             var opt = document.createElement('option');
             opt.innerHTML = Memoryval[i];
             opt.value = Memoryval[i];
             sel.appendChild(opt);
         }
         $("#divOwnBorrow").hide();
         $("#divFixed").show();
         $("#divUtilization").hide();
         $("#spanid").show();

     }
     if (this.value == "CPU") {
         for (var i = 0; i < CPU.length; i++) {
             var opt = document.createElement('option');
             opt.innerHTML = CPU[i];
             opt.value = CPU[i];
             sel.appendChild(opt);
         }
         $('#ddltype option[value=OwnBorrow]').prop('selected', true);
         // $("#ddltype select").text("OwnBorrow");
         $("#divOwnBorrow").show();
         $("#divFixed").hide();
         $("#divUtilization").hide();
         $("#spanid").hide();
     }
 });
posted Nov 16, 2015 by Chirag Gangdev

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
I don't see any error in the line for (var i = 0; i < Memoryval.length; i++) so seems to be error at some place, unfortunately I can not run the program at my end as it has lot of local things.

Please provide the localized program which can be executed without context or you need to debug at ur end.

1 Answer

0 votes

I suspect that you have a non breaking space before Memoryval in that line, and it got removed

$ charinfo " " " "
U+00A0 NON-BREAKING SPACE [Zs]
U+0020 SPACE [Zs]

It is possible to write a non breaking space, for instance pressing apple icon+space on OS X will cause this character to printed. These spaces might cause problems for The Spring Framework.

answer Apr 13, 2016 by Manikandan J
Similar Questions
0 votes

Write validation functions and modify the onSubmit event Handler in the form code to validate the following form fields:

  1. Phone Number
    • Must be entered
    • Must be below format
    XXX-XXX-XXXX
    XXX.XXX.XXXX
    XXX XXX XXXX
+1 vote

I want the javascript API which could capture the screen of the client. Does anyone knows about it?

...