4 Replies - 465 Views - Last Post: 23 October 2013 - 09:52 AM

#1 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 463
  • View blog
  • Posts: 3,171
  • Joined: 12-January 10

select vale from html select box

Posted 21 October 2013 - 06:06 AM

I have to use IE 9 and 10

 var ddb_COMPARABLE3 = document.getElementById('PS_FORM/COMPARABLE3/Design');
 var selectedItem6 = ddb_COMPARABLE3.options[ddb_COMPARABLE3.selectedIndex].value;
 if (selectedItem == 'Other')


the above code does not work

error returned for the above code thrown on the options[]
SCRIPT438: Object doesn't support this property or method 


select box is dynamically created

how can i get the value of the select box if I cant use ooptions?

thanks

Is This A Good Question/Topic? 0
  • +

Replies To: select vale from html select box

#2 JMRKER  Icon User is offline

  • D.I.C Addict

Reputation: 128
  • View blog
  • Posts: 828
  • Joined: 25-October 08

Re: select vale from html select box

Posted 22 October 2013 - 06:49 PM

Have you tried...?

var ddb_COMPARABLE3 = document.getElementById('PS_FORM/COMPARABLE3/Design');
var selectedItem6 = ddb_COMPARABLE3.value;
if (selectedItem == 'Other') { ...



BUT, I'm not sure that a '/' is a valid id character.
Show some more code if it does not work.
Was This Post Helpful? 0
  • +
  • -

#3 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 463
  • View blog
  • Posts: 3,171
  • Joined: 12-January 10

Re: select vale from html select box

Posted 23 October 2013 - 08:56 AM

I just did the following:

3 if (document.getElementById('PS_FORM/COMPARABLE3/Design') == 'Other') 



and it worked

i hate ie lol
Was This Post Helpful? 0
  • +
  • -

#4 JMRKER  Icon User is offline

  • D.I.C Addict

Reputation: 128
  • View blog
  • Posts: 828
  • Joined: 25-October 08

Re: select vale from html select box

Posted 23 October 2013 - 09:44 AM

View PostDarenR, on 23 October 2013 - 09:56 AM, said:

I just did the following:

3 if (document.getElementById('PS_FORM/COMPARABLE3/Design') == 'Other') 



and it worked

i hate ie lol


I'm not sure WHY that worked as you are testing the element, not the value of the element.
It should fail as stated, but you might be doing something else elsewhere (?)

It would be nice the see the rest of your code or a link to the page where it is being used this way.
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3487
  • View blog
  • Posts: 11,897
  • Joined: 12-December 12

Re: select vale from html select box

Posted 23 October 2013 - 09:52 AM

That shouldn't work.

The first posted-code used selectedItem6, but then switched to selectedItem.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1