This discussion is archived
2 Replies Latest reply: Mar 8, 2012 7:13 AM by gimbal2 RSS

problem doing childAppend

920164 Newbie
Currently Being Moderated
Hi all
I am adding the following script at the end of my JSP to add a hidden field but it dosent work unless i add an alert statment before appending the new element, dose anyone have any explanation of this strange behavior?

<%
String transactionNo =request.getParameter("transactionNo");
System.out.println("PSS At error footer jsp -----" + transactionNo);
%>
<script language="JavaScript" type="text/javascript">
var inputFeild = document.createElement("input");
inputFeild.type = "hidden";
inputFeild.name = "transactionNo";
inputFeild.value = "<%=transactionNo%>";
var formsCollection = document.getElementsByTagName('form');
// i i add alert here, it works!!!!
for(var i=0;i<formsCollection.length;i++){
document.getElementsByTagName('form')[0].appendChild(inputFeild);
}     
</script>

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points