Closed Thread Icon

Preserved Topic: getting form input values... (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=17970" title="Pages that link to Preserved Topic: getting form input values... (Page 1 of 1)" rel="nofollow" >Preserved Topic: getting form input values... <span class="small">(Page 1 of 1)</span>\

 
cybergrafx
Paranoid (IV) Inmate

From: Earth
Insane since: Sep 2000

posted posted 05-16-2001 02:28

ok this is really bugging me:

I'm trying to grab the value(s) of all elements in a form, I did this:

code:
for (i = 0; i < document.frmTorchPackage.elements.length; i++) {
if (document.frmTorchPackage.elements.type = "radio") {
if (document.frmTorchPackage.elements(i).checked == true) {
myVar = document.frmTorchPackage.elements(i).name



I then use the switch statement to grab the value of myVar and execute the necessary statements..... now the problem is

1. myVar returns ' undefined ' but if I do

alert(document.frmTorchPackage.elements(i).name) <- I get a value....

2. that code doens't even work at all in Netscape, I get a weird

document.frmTorchPackage.elements.length is not a function error

3. I know you can do a nested if statements, but is a nested switch statement possible or advisable? I've not been able to find any documentation(s) on this.....

can someone please shed some lights on what I'm doing wrong here, please...

thanx in advance...

Here is a trustworthy saying that deserves full acceptance: Christ Jesus
came into the world to save sinners -of whom I am the worst. But for that
very reason I was shown mercy so that in me, the worst of sinners, Christ Jesus might display his unlimited patience as an example for those who would believe on him and receive eternal life. I Timothy 1:15

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

posted posted 05-16-2001 02:46

It's been a while since I've done stuff like this with forms but I think you should be using [] square brackets instead of () parentheses.

document.frmTorchPackage.elements[i].name


linear
Paranoid (IV) Inmate

From: other places
Insane since: Mar 2001

posted posted 05-16-2001 05:40

ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding ding

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 05-16-2001 09:16

Here's the correct code:

for (i = 0; i < document.frmTorchPackage.elements.length; i++) {
&nbsp;&nbsp;&nbsp;&nbsp;if ((document.frmTorchPackage.elements[i].type == "radio") && (document.frmTorchPackage.elements[i].checked == true)) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myVar = document.frmTorchPackage.elements[i].name;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alert(myVar);
&nbsp;&nbsp;&nbsp;&nbsp;}
}

cybergrafx
Paranoid (IV) Inmate

From: Earth
Insane since: Sep 2000

posted posted 05-16-2001 17:12

thanx everyone, you've all been very helpful.

Here is a trustworthy saying that deserves full acceptance: Christ Jesus
came into the world to save sinners -of whom I am the worst. But for that
very reason I was shown mercy so that in me, the worst of sinners, Christ Jesus might display his unlimited patience as an example for those who would believe on him and receive eternal life. I Timothy 1:15

« BackwardsOnwards »

Show Forum Drop Down Menu