IWETHEY v. 0.3.0 | TODO
1,095 registered users | 1 active user | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Need JavaScript bug help
In the following code, I am trying to get the value of the Select box. It works in Mozilla, but not IE. Any help would be apprecated. -t-
\n{form name="mainform" method="post" action="somewhere.htm" target="_blank">\n\t{input type="submit" name="removebut" value="Press Me" \n\t\tstyle="width:200" onClick="buttonsClick('removebut')">\n\t{p>\n\t{select name="filterset">\n\t\t{option>foo\n\t\t{option>bar\n\t\t{option>foo bar\n\t{/select>\n\t{p>\n\t{input type="text" name="mybox">\n{/form>\n\n\n{script language="JavaScript">\n\t//-----------------------\t\n\tfunction buttonsClick(butName) {  // button handler\n\t\tif (butName=='removebut') {\n\t\t\t/////alert(document.mainform.mybox.value);\n\n\t\t\tselectedPosition = \n\ndocument.mainform.filterset.selectedIndex;\n\n\t\t\tpicked = \n\ndocument.mainform.filterset.options[selectedPosition].value;\n\t\t\t\n\t\t\talert('test 3: pos=' + selectedPosition + ' value=' + \n\npicked);\n\t\t}\n\t}\n{/script>\n\n\n

(Less-thans substituted with curlie braces)
________________
oop.ismad.com
New Try closing the "option" tags
===

Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]
New Tried that, no go
The original (with problem) had closings anyhow; I just rushed it for the sample when I substituted it with foo-bar stuff. I won't do it again.
________________
oop.ismad.com
Expand Edited by tablizer July 23, 2005, 12:10:15 AM EDT
New Need a value attribute for the options
you've set the text for the options but assigned no value.
\n         <select name="filterset">\n            <option value='foo'>foo\n            <option value='bar'>bar\n            <option value='foo bar'>foo bar\n         </select>\n

New Thanks, it worked!
However, it does bring up a couple of questions:

1. Why did it work in Mozilla without the Value tag?

2. How does one reference the description text in JS?
________________
oop.ismad.com
New Mozilla probably defaults
Means that <option> is probably not treated the same as <option value=''>. Anyhow, it's not a behavior that should be relied upon.

The text can be retrieved by using .text instead of .value.
   document.mainform.filterset.options[selectedPosition].text;

New Can anybody recommend a good on-line JavaScript reference?
My dot-com-fire-sale books are getting outdated. Thanks for the tips.
________________
oop.ismad.com
New Wikipedia?
[link|http://en.wikipedia.org/wiki/JavaScript|JavaScript] and [link|http://en.wikipedia.org/wiki/Ecmascript|ECMAScript]. They seem to be decent references with pointers to other sources.

HTH.

Cheers,
Scott.
New Various References
I generally fallback on the O'Reilly [link|http://www.oreilly.com/catalog/dhtmlref2/|DHTML] and [link|http://www.oreilly.com/catalog/jscript4/|JavaScript] books. [link|http://www.dannyg.com/pubs/jsb/|Javascript Bible] is also good but after reading it, I rarely fall back to it for reference purposes. Anyhow, if you're in the market, those are probably the three best.

There's lots of web resources as well, but I usually just google and end up at random places. Two that I've bookmarked but don't use regularly are [link|http://javascript-reference.info/|Javascript crib] and [link|http://webref.info/default.asp?|WebRef].

New Oldie but goodie
[link|http://wp.netscape.com/eng/mozilla/3.0/handbook/javascript/|http://wp.netscape.c...dbook/javascript/]
===

Purveyor of Doc Hope's [link|http://DocHope.com|fresh-baked dog biscuits and pet treats].
[link|http://DocHope.com|http://DocHope.com]
New For future reference, just backslash escape the <
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New LRPD: But don't get all fretty-pants on us.



"Whenever you find you are on the side of the majority, it is time to pause and reflect"   --Mark Twain

"The significant problems we face cannot be solved at the same level of thinking we were at when we created them."   --Albert Einstein

"This is still a dangerous world. It's a world of madmen and uncertainty and potential mental losses."   --George W. Bush
     Need JavaScript bug help - (tablizer) - (11)
         Try closing the "option" tags -NT - (drewk) - (1)
             Tried that, no go - (tablizer)
         Need a value attribute for the options - (ChrisR) - (6)
             Thanks, it worked! - (tablizer) - (5)
                 Mozilla probably defaults - (ChrisR) - (4)
                     Can anybody recommend a good on-line JavaScript reference? - (tablizer) - (3)
                         Wikipedia? - (Another Scott)
                         Various References - (ChrisR)
                         Oldie but goodie - (drewk)
         For future reference, just backslash escape the < -NT - (admin) - (1)
             LRPD: But don't get all fretty-pants on us. -NT - (tuberculosis)

An implementation of non-trivial covariant returns for non-varadic virtual functions.
77 ms