1

I am trying to pass an array of strings to a javascript function from jsp.

Following is the part of code that calls the function:

<a href="#" onclick='loadData("<%=entry.getDisplayName()%>","<%=entry.getModuleName() %>","<%=entry.getFileDesc()%>","<%=entry.getFileID()%>")'>Edit</a>

Entry is an object and the type for ModuleName is as follows:

private String[] moduleName;

I have put proper getters and setters for the same.

This is the function implementation part:

    function loadData(val1, val2, val3, val4) {
    document.getElementById("editDisplayName").value = val1;
    document.getElementById("selectedFile").innerHTML = val1
            + '<span><a onclick="displayUpload()" style="padding: 10px; cursor: pointer; cursor: hand;">X</a>';
    document.getElementById("editDescription").value = val3;
    document.getElementById("fileID").value = val4;
    var modules = val2;
    for(var index=0;index < modules.length;index++)
        {
        alert(modules[index]);
        }

    jQuery('#edit-form').dialog('open');
    return false
}

When run, it shows gibberish values.

Can someone please tell me what am I doing wrong??

Himesh Nandani
  • 121
  • 1
  • 8

0 Answers0