Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NS & getting the value of a <select> 1

Status
Not open for further replies.

link9

Programmer
Nov 28, 2000
3,387
US
Hello everyone --

Ran into a bit of a snag this morning. I have a <select> that I need to send the value of to a javascript function and parse out two simple values from.

I've been saddled with designing this site for NS, and this problem occurs in 4.x NS browsers (fine in IE and NS6.x).

Here is the <select>

<select name=period1 onChange=&quot;setPeriod(this.value,1);&quot;>
<option value=20000>Year 2000</option>
<option value=20001>2000 Q1</option>
<option value=20002>2000 Q2</option>
<option value=20003>2000 Q3</option>
<option value=20004>2000 Q4</option>
<option value=20010>Year 2001</option>
<option value=20011>2001 Q1</option>
<option value=20012>2001 Q2</option>
<option value=20013>2001 Q3</option>
<option value=20014>2001 Q4</option>
<option value=20020>Year 2002</option>
<option value=20021>2002 Q1</option>
</select>

Here's the function:

function setPeriod(val,i){
var str = new String(val);
var y = str.slice(0,4);
var q = str.slice(4,5);
//alert(y+','+q);
alert(val);
}

In NS, the alert message returns 'null' every time in 4.x versions. What can I do to modify this to work w/ this product?

Thanks! :)
paul
penny.gif
penny.gif
 
try

setPeriod(this.options[this.selectedIndex].value,1) Victor
 
I'm pretty sure that Netscape doesn't support slice() method for string object. I didn't find any trace of it in Netscape's Developers documentation.
You should you substring() instead.
 
Thanks, Victor.

Worked perfectly.

:)
paul
penny.gif
penny.gif
 
starway, thx for the heads up, but as it turns out, it does work.

Try the quick refs at:


next time. ;-) I have learned not to trust NS -- documentation, their browser, nothing. Kick and scream and stand on my head every time I ever have to make a site compatible with it.

:)
paul
penny.gif
penny.gif
 
:)

:) hey! but netscrap make us follow the Rulezzz :)

:) Victor
 
rulez schmulez

In the US, we have this thing called the Declaration of Independence that has a great line in it:

that whenever any Form of Government becomes destructive of these Ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its Foundation on such Principles, and organizing its Powers in such Form, as to them shall seem most likely to effect their Safety and Happiness

Replace the word 'Government' with the word 'Technology', the phrase 'Safety and Happiness' with 'Efficiency of Development' and you get:

that whenever any Form of Technology becomes destructive of these Ends, it is the Right of the People to alter or to abolish it, and to institute new Technology, laying its Foundation on such Principles, and organizing its Powers in such Form, as to them shall seem most likely to effect their Efficiency of Development

pretty sums up my feelings on the whole NS (and any other dead technology) issue. I used to be a proponent. Really, I was.

;-)
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top