CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript programming (http://www.codingforums.com/forumdisplay.php?f=2)
-   -   Output Label instead of Value (http://www.codingforums.com/showthread.php?t=270776)

Ilan 08-18-2012 02:13 AM

Output Label instead of Value
 
Hi Everyone

The code that I am working on is here: http://www.payitforwardfriends.com/converter.html

I'm trying to make it so that in the output when you convert from one substance to another it says what you are converting from (as in it says 1 cup of flour).

The problem is "substance" is for the value, and not for the label. How do I make the label show up instead?

Currently, it's coming up as [object HTMLSelectElement].

Thanks so much!

Old Pedant 08-18-2012 02:30 AM

Same way it is done for the other <select>s.

Look at them:
Code:

var inunittext = inunit.options[inunit.selectedIndex].text;
var outunittext = outunit.options[outunit.selectedIndex].text;
var densunittext = densunit.options[densunit.selectedIndex].text;

So
Code:

var substance = document.getElementById("substance");
var substanceAsText = substance.options[substance.selectedIndex].text;

I used substanceAsText because you already have a variable named substanceText used for another purpose.

Ilan 08-18-2012 04:09 AM

That works. Thanks!


All times are GMT +1. The time now is 12:08 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.