|
-
Jan 17th, 2002, 11:10 AM
#1
Thread Starter
Evil Genius
wheres tham thar elements ?!?!?
-
Jan 17th, 2002, 01:53 PM
#2
Addicted Member
It's easy to declare an object with properties in JavaScript--you don't. Instead, you just start using the properties in your code:
elementTxtBox.name = "myControl";
elementTxtBox.value = "Yes";
Unfortunately, I can't help you with defining methods for elementTxtBox.
cudabean
-
Jan 17th, 2002, 03:29 PM
#3
Addicted Member
Oops, made a mistake. It's not quite that easy:
elementTxtBox.name = new Object();
elementTxtBox.name = "myControl";
elementTxtBox.value = "Yes";
cudabean
-
Jan 17th, 2002, 03:31 PM
#4
Addicted Member
Grrr. This is finally correct:
elementTxtBox = new Object();
elementTxtBox.name = "myControl";
elementTxtBox.value = "Yes";
-
Jan 17th, 2002, 04:19 PM
#5
Thread Starter
Evil Genius
Thanks cudabean,
If I understand this right though, you're defining a new element on the page?
My idea (if it's possible) is to use an existing one. I could use :
Code:
FunctionProper() {
alert(document.forms.elements.item("text1"))
}
In the actual function, but if I had 5 function doing the same thing, I was hoping to make a general function with the messagebox/alert code in, and just call this from the 5 functions I need, passing in the name of the element/textbox I want to display the value of. 
Not sure if that one made too much sense there, sorry.
Thanks!
-
Jan 17th, 2002, 06:03 PM
#6
Addicted Member
I defined a new object that doesn't relate to anything on the page. I think I misunderstood your original premise. The object I created is only used to store data in a structure.
In looking back at your original message I think I understand better.
I think your original code is close to correct, except that I don't think that
document.forms.elements.item("text1") works.
document.forms.elements.item(1) works though.
document.forms[0].elements["text1"] should work.
document.form.text1 should work too.
HTH
cudabean
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|