problem on jsp select box and javascript

K

KelvinWongYW

i have a select box and the option is like below:

<option value='1111' txn='PYM' accType='C'>111232</option>

while i would like to get the accType in javascript, i use:
document.mainform.dacc.options[1].accType

but i failed to get value and it alert undefine.
however, getting the value is successful:
document.mainform.dacc.options[1].value

does anyone know how can i get acctype?
i have try quite a lot method

thanks
 
D

David Mark

i have a select box and the option is like below:

<option value='1111' txn='PYM' accType='C'>111232</option>

This is (very) invalid markup.
while i would like to get the accType in javascript, i use:
document.mainform.dacc.options[1].accType

That should be:

document.forms.mainform.elements.dacc.options[1].accType

But that won't help your problem.
but i failed to get value and it alert undefine.
however, getting the value is successful:
document.mainform.dacc.options[1].value

does anyone know how can i get acctype?
i have try quite a lot method

I would say try getAttribute, but it won't help if your current
attempt fails in IE (IE's getAttribute implementation reads properties
rather than attributes.)
 
K

KelvinWongYW

i have a select box and the option is like below:
<option value='1111' txn='PYM' accType='C'>111232</option>

This is (very) invalid markup.


while i would like to get the accType in javascript, i use:
document.mainform.dacc.options[1].accType

That should be:

document.forms.mainform.elements.dacc.options[1].accType

But that won't help your problem.


but i failed to get value and it alert undefine.
however, getting the value is successful:
document.mainform.dacc.options[1].value
does anyone know how can i get acctype?
i have try quite a lot method

I would say try getAttribute, but it won't help if your current
attempt fails in IE (IE's getAttribute implementation reads properties
rather than attributes.)
thanks very much

document.mainform.dacc.options[1].accType <-- it does not work also

i would the page can be view at ie and firefox
 
K

KelvinWongYW

i have a select box and the option is like below:
<option value='1111' txn='PYM' accType='C'>111232</option>

This is (very) invalid markup.


while i would like to get the accType in javascript, i use:
document.mainform.dacc.options[1].accType

That should be:

document.forms.mainform.elements.dacc.options[1].accType

But that won't help your problem.


but i failed to get value and it alert undefine.
however, getting the value is successful:
document.mainform.dacc.options[1].value
does anyone know how can i get acctype?
i have try quite a lot method

I would say try getAttribute, but it won't help if your current
attempt fails in IE (IE's getAttribute implementation reads properties
rather than attributes.)

it work if i use getattribute in both firefox and ie 6.0
 
D

David Mark

On Feb 14, 11:07 pm, (e-mail address removed) wrote:
This is (very) invalid markup.
while i would like to get the accType in javascript, i use:
document.mainform.dacc.options[1].accType
That should be:
document.forms.mainform.elements.dacc.options[1].accType

But that won't help your problem.
but i failed to get value and it alert undefine.
however, getting the value is successful:
document.mainform.dacc.options[1].value
does anyone know how can i get acctype?
i have try quite a lot method
I would say try getAttribute, but it won't help if your current
attempt fails in IE (IE's getAttribute implementation reads properties
rather than attributes.)

thanks very much

document.mainform.dacc.options[1].accType <-- it does not work also

That's what I meant by "But that won't help your problem." It is just
the most compatible way to reference a form element.
 
D

David Mark

On Feb 14, 11:07 pm, (e-mail address removed) wrote:
This is (very) invalid markup.
while i would like to get the accType in javascript, i use:
document.mainform.dacc.options[1].accType
That should be:
document.forms.mainform.elements.dacc.options[1].accType

But that won't help your problem.
but i failed to get value and it alert undefine.
however, getting the value is successful:
document.mainform.dacc.options[1].value
does anyone know how can i get acctype?
i have try quite a lot method
I would say try getAttribute, but it won't help if your current
attempt fails in IE (IE's getAttribute implementation reads properties
rather than attributes.)

it work if i use getattribute in both firefox and ie 6.0

Then it must have worked all along in IE as the behavior is the same
when using getAttribute.
 
P

Paul Wilkins

i have a select box and the option is like below:

<option value='1111' txn='PYM' accType='C'>111232</option>
does anyone know how can i get acctype?

You are going to have trouble when you try to define invalid
attributes.
Perhaps using id and class attributes will help instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,145
Latest member
web3PRAgeency
Top