• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

form element -- objeect null

 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
If I have a form element, for example,
<select name="selTest" id="selTest">
<option> ...//code to add options
</select>
or
<input type = "text" name="txtTest" value="xxx">
In a javascript function, if I refer to these form elements using their names directly, it is OK. However, if I use a variable, for example,
function changeValue(frm, para1){
frm.para1.value= ....;
}
or
function changeValue(frm, para1){
var ele=para1;
frm.ele.value=....;
}
Then call changeValue(form, "txtTest"), I got an error that para1 or ele is null or not object.
Can someone tell me what is wrong and how to fix it?
 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike,
It looks like your function is interpreting the parameters you pass it as strings, not form elements. It's hard to say how to fix it without knowing where "changeValue(...)" is called, and on what event, but I would try one of these two things:

hth,
g.
 
I've got no option but to sell you all for scientific experiments. Or a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic