Hi. I am having trouble getting the value of an input field and don’t understand why. Here is a snippet of what I’m working on (inside a JSP):
[CODE]<%
List nodes = (List)request.getAttribute(FileListServlet.NODELIST_ATTRIBUTE);
ResourceBundle bundle = ResourceBundle.getBundle(“com.corp.custom.strings”, request.getLocale());
String vpathParam = “list_files_portlet-vpath”;
//Create the data needed for a path cookie-crumb.
CSVPath curPath = (CSVPath)session.getAttribute(FileListServlet.VPATH_SESSION_KEY);
Stack pathStack = new Stack();
for (CSVPath parentPath = curPath.getParentPath();
!parentPath.toString().equals(CSVPath.SERVER_SLASH);
parentPath = parentPath.getParentPath())
{
pathStack.push(parentPath);
}
%>
<script language=”javascript”>
//This JavaScript function does the actual posting back to our
//FileList servlet. It sets the vpath parameter based on what
//the user selected.
function submit_to_list_file_portlet(path)
{
alert(document.getElementById(“<%=vpathParam%>”).value);
alert(document.forms[‘corp_customer_list_files_portlet_form’].elements[‘<%=vpathParam%>’].value);
var form = document.forms.corp_customer_list_files_portlet_form;
form.elements[‘<%=vpathParam%>’].value = path;
form.submit();
}
</script>
<form name=”corp_customer_list_files_portlet_form” method=”post”>
<input type=”hidden” id=”<%=vpathParam%>” name=”<%=vpathParam%>”>
</form>
The first alert shows a blank alert. The second gives me an error:
Line: 3236
Char: 17
Error: ‘elements.list_files_portlet-vpath’ is null or not an object
Code: 0
I don’t understand: why can’t I access the value of the input field on the form?
Secondly, what is that line number referring to? My JSP doesn’t have that many lines.