Forum Stats

  • 3,784,406 Users
  • 2,254,934 Discussions
  • 7,880,806 Comments

Discussions

problem doing childAppend

920164
920164 Member Posts: 47
edited Mar 8, 2012 10:13AM in JavaServer Pages (JSP) and JSTL
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>

Answers

  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy
    I know I told you to pick the right forum for a question, but you are not making things easier by running two threads with exactly the same question. Do it the next time you have a question.

    2359360
  • gimbal2
    gimbal2 Member Posts: 11,949 Gold Trophy
    No, and I'm afraid that this is a javascript question, not a JSP or Java question. I predict that this thread (and your duplicate one on the JSP forum) are going to be locked very soon. To get better help, find a javascript forum.
This discussion has been closed.