Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass a dynamic generate form name to javascript function

 
lijun wang
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is javascript
------------------------------------------------
calcTotals(price,form){
alert(form);
var arrElem = document.form.elements;
}
-------------------------------------------------
#{pc_DetailView.namespace}calcTotals(this,'view#{pc_DetailView.namespace}:form1')

alert(form) output: viewPC_7_0_OKD_:form1

but has error on "arrElem = document.form.elements"
"document.form has no properities"
I think "document.form.elements" should be: "document.viewPC_7_0_OKD_:form1.elements" instead of "document.form.elements"

please help me!!
 
Nimchi Yung
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you just use the form that you passed to your javascript function?

--Nimchi
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
document.forms[formName]

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic