Re: [ot] Re: question on javascript... [solved]

2003-10-20 Thread Jacob Wilson
Just tested this... It works Mark... I think I was missing 'document'... Thanks for 
the help and suggestions...
 



function getValue(optionName, hiddenValue) {
 var s = document.frmTest.elements[optionName];
 for (var i=0; i wrote:
I was on the wrong lines anyhow..

forms[] and elements[] deal with the index and/or the names. options[] 
requires the index.

the value is a property of the element not the option (at least i 
recall things being like that.

I'd just pass the value of the element as an argument But my apologies 
from not reading the question properly in the first place.

Cheers Mark

On Monday, October 20, 2003, at 03:38 PM, Jacob Wilson wrote:

>
> I get that error when I pass the element name only !!
>
> function getValue(form, optionName,hiddenValue) {
> s = form.elements[optionName];
> for(i = 0;i < s.options.length;i++) {
> if(s.options[i].value == hiddenValue) {
> s.options[i].selected = true;
> break;
> }
> }
> }
>
>
> optionName is the element name and the error "elements.optionName is 
> not null or an object" when I try to use s.options.length...
>
>
> Mark Lowe wrote:
> You can specify an index or the name of the element.
>
> Likewise with the array of forms in the page.. Some folks prefer using
> the
>
> document.myform.myelement
>
> syntax.
>
> But you can use the element name also.
>
> Cheers Mark
>
> On Monday, October 20, 2003, at 03:14 PM, Jeff Kyser wrote:
>
>> form.elements is an array, and you'd have to specify
>> it by index:
>>
>> s = form.elements[i];
>>
>> where i was a supplied integer in the range 0..form.elements.length-1,
>> or
>>
>> s = form.optionName;
>>
>> if 'optionName' was a valid name for a form element.
>>
>> HTH,
>>
>> -jeff
>>
>> On Monday, October 20, 2003, at 08:55 AM, Jacob Wilson wrote:
>>
>>> Thanks for the help Mark... when I do this, it says
>>> elements.optionName is not null or an object... Any clue??? Thanks!
>>>
>>> Mark Lowe wrote:Those variable don't really
>>> need to be global.
>>>
>>> function getValue(form, optionName,hiddenValue) {
>>> s = form.elements[optionName];
>>> for(i = 0;i < s.options.length;i++) {
>>> if(s.options[i].value == hiddenValue) {
>>> s.options[i].selected = true;
>>> break;
>>> }
>>> }
>>> }
>>>
>>> onsomeformevent="getValue(this.form,'foo','bar')"
>>>
>>> Cheers Mark
>>>
>>> On Monday, October 20, 2003, at 07:55 AM, Jacob Wilson wrote:
>>>
 Thanks Matt... It sure helped...

 Actually, now, I tried to put it as a common function like...

 function getValue(optionName, hiddenValue) {
 var s = document.forms[0].optionName;
 for (var i=0; i> if ( s.options[i].value == hiddenValue ) {
 s.options[i].selected = true;
 break;
 }
 }
 }

 where optionName is the name of the selectboxes that r in the form 
 --
 when I try to use 'optionName' it throws an error when I try to get
 the length saying option is null... Am I missing something here???

 Please let me know... Thanks in advance...

 -Jacob

 "Kruse, Matt" wrote:
> This is a basic question... Can I find the index of a select box,
> if I have the value or the text ???
> document.formName.optionName.options["C"].selected=true
> -- This won't work!!

 You need to loop through each option, checking to see it's value and
 then
 checking it.

 var s = document.formname.optionname;
 for (var i=0; i if (s.options[i].value=="C") {
 s.selected=true;
 }
 }

 Or, using functions at
 http://www.mattkruse.com/javascript/validations/ you
 can do:

 setInputValue(document.formname.optionname,"C");

 Be careful - multiple options are allowed to have the same value!

 Matt Kruse




 -
 Do you Yahoo!?
 The New Yahoo! Shopping - with improved product search
>>>
>>>
>>> -
>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>>> For additional commands, e-mail: [EMAIL PROTECTED]
>>>
>>>
>>>
>>> -
>>> Do you Yahoo!?
>>> The New Yahoo! Shopping - with improved product search
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> -
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands,

Re: [ot] Re: question on javascript...

2003-10-20 Thread Mark Lowe
I was on the wrong lines anyhow..

forms[] and elements[] deal with the index and/or the names. options[] 
requires the index.

the value is a property of the element not the option (at least i 
recall things being like that.

I'd just pass the value of the element as an argument But my apologies 
from not reading the question properly in the first place.

Cheers Mark

On Monday, October 20, 2003, at 03:38 PM, Jacob Wilson wrote:

I get that error when I pass the element name only !!

function getValue(form, optionName,hiddenValue) {
s = form.elements[optionName];
 for(i = 0;i < s.options.length;i++) {
 if(s.options[i].value == hiddenValue) {
 s.options[i].selected = true;
 break;
 }
 }
 }
optionName is the element name and the error "elements.optionName is 
not null or an object" when I try to use s.options.length...

Mark Lowe <[EMAIL PROTECTED]> wrote:
You can specify an index or the name of the element.
Likewise with the array of forms in the page.. Some folks prefer using
the
document.myform.myelement

syntax.

But you can use the element name also.

Cheers Mark

On Monday, October 20, 2003, at 03:14 PM, Jeff Kyser wrote:

form.elements is an array, and you'd have to specify
it by index:
s = form.elements[i];

where i was a supplied integer in the range 0..form.elements.length-1,
or
s = form.optionName;

if 'optionName' was a valid name for a form element.

HTH,

-jeff

On Monday, October 20, 2003, at 08:55 AM, Jacob Wilson wrote:

Thanks for the help Mark... when I do this, it says
elements.optionName is not null or an object... Any clue??? Thanks!
Mark Lowe wrote:Those variable don't really
need to be global.
function getValue(form, optionName,hiddenValue) {
s = form.elements[optionName];
for(i = 0;i < s.options.length;i++) {
if(s.options[i].value == hiddenValue) {
s.options[i].selected = true;
break;
}
}
}
onsomeformevent="getValue(this.form,'foo','bar')"

Cheers Mark

On Monday, October 20, 2003, at 07:55 AM, Jacob Wilson wrote:

Thanks Matt... It sure helped...

Actually, now, I tried to put it as a common function like...

function getValue(optionName, hiddenValue) {
var s = document.forms[0].optionName;
for (var i=0; i> if ( s.options[i].value == hiddenValue ) {
s.options[i].selected = true;
break;
}
}
}
where optionName is the name of the selectboxes that r in the form 
--
when I try to use 'optionName' it throws an error when I try to get
the length saying option is null... Am I missing something here???

Please let me know... Thanks in advance...

-Jacob

"Kruse, Matt" wrote:
This is a basic question... Can I find the index of a select box,
if I have the value or the text ???
document.formName.optionName.options["C"].selected=true
-- This won't work!!
You need to loop through each option, checking to see it's value and
then
checking it.
var s = document.formname.optionname;
for (var i=0; i if (s.options[i].value=="C") {
s.selected=true;
}
}
Or, using functions at
http://www.mattkruse.com/javascript/validations/ you
can do:
setInputValue(document.formname.optionname,"C");

Be careful - multiple options are allowed to have the same value!

Matt Kruse



-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [ot] Re: question on javascript...

2003-10-20 Thread Jacob Wilson

I get that error when I pass the element name only !! 
 
function getValue(form, optionName,hiddenValue) {
s = form.elements[optionName];
 for(i = 0;i < s.options.length;i++) {
 if(s.options[i].value == hiddenValue) {
 s.options[i].selected = true;
 break;
 }
 }
 }

 
optionName is the element name and the error "elements.optionName is not null or an 
object" when I try to use s.options.length...


Mark Lowe <[EMAIL PROTECTED]> wrote:
You can specify an index or the name of the element.

Likewise with the array of forms in the page.. Some folks prefer using 
the

document.myform.myelement

syntax.

But you can use the element name also.

Cheers Mark

On Monday, October 20, 2003, at 03:14 PM, Jeff Kyser wrote:

> form.elements is an array, and you'd have to specify
> it by index:
>
> s = form.elements[i];
>
> where i was a supplied integer in the range 0..form.elements.length-1, 
> or
>
> s = form.optionName;
>
> if 'optionName' was a valid name for a form element.
>
> HTH,
>
> -jeff
>
> On Monday, October 20, 2003, at 08:55 AM, Jacob Wilson wrote:
>
>> Thanks for the help Mark... when I do this, it says 
>> elements.optionName is not null or an object... Any clue??? Thanks!
>>
>> Mark Lowe wrote:Those variable don't really 
>> need to be global.
>>
>> function getValue(form, optionName,hiddenValue) {
>> s = form.elements[optionName];
>> for(i = 0;i < s.options.length;i++) {
>> if(s.options[i].value == hiddenValue) {
>> s.options[i].selected = true;
>> break;
>> }
>> }
>> }
>>
>> onsomeformevent="getValue(this.form,'foo','bar')"
>>
>> Cheers Mark
>>
>> On Monday, October 20, 2003, at 07:55 AM, Jacob Wilson wrote:
>>
>>> Thanks Matt... It sure helped...
>>>
>>> Actually, now, I tried to put it as a common function like...
>>>
>>> function getValue(optionName, hiddenValue) {
>>> var s = document.forms[0].optionName;
>>> for (var i=0; i> if ( s.options[i].value == hiddenValue ) {
>>> s.options[i].selected = true;
>>> break;
>>> }
>>> }
>>> }
>>>
>>> where optionName is the name of the selectboxes that r in the form --
>>> when I try to use 'optionName' it throws an error when I try to get
>>> the length saying option is null... Am I missing something here???
>>>
>>> Please let me know... Thanks in advance...
>>>
>>> -Jacob
>>>
>>> "Kruse, Matt" wrote:
 This is a basic question... Can I find the index of a select box,
 if I have the value or the text ???
 document.formName.optionName.options["C"].selected=true
 -- This won't work!!
>>>
>>> You need to loop through each option, checking to see it's value and
>>> then
>>> checking it.
>>>
>>> var s = document.formname.optionname;
>>> for (var i=0; i if (s.options[i].value=="C") {
>>> s.selected=true;
>>> }
>>> }
>>>
>>> Or, using functions at
>>> http://www.mattkruse.com/javascript/validations/ you
>>> can do:
>>>
>>> setInputValue(document.formname.optionname,"C");
>>>
>>> Be careful - multiple options are allowed to have the same value!
>>>
>>> Matt Kruse
>>>
>>>
>>>
>>>
>>> -
>>> Do you Yahoo!?
>>> The New Yahoo! Shopping - with improved product search
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>>
>> -
>> Do you Yahoo!?
>> The New Yahoo! Shopping - with improved product search
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

Re: [ot] Re: question on javascript...

2003-10-20 Thread Mark Lowe
You can specify an index or the name of the element.

Likewise with the array of forms in the page.. Some folks prefer using 
the

document.myform.myelement

syntax.

But you can use the element name also.

Cheers Mark

On Monday, October 20, 2003, at 03:14 PM, Jeff Kyser wrote:

form.elements is an array, and you'd have to specify
it by index:
	s = form.elements[i];

where i was a supplied integer in the range 0..form.elements.length-1, 
or

	s = form.optionName;

if 'optionName' was a valid name for a form element.

HTH,

-jeff

On Monday, October 20, 2003, at 08:55  AM, Jacob Wilson wrote:

Thanks for the help Mark... when I do this, it says 
elements.optionName is not null or an object... Any clue??? Thanks!

Mark Lowe <[EMAIL PROTECTED]> wrote:Those variable don't really 
need to be global.

function getValue(form, optionName,hiddenValue) {
s = form.elements[optionName];
for(i = 0;i < s.options.length;i++) {
if(s.options[i].value == hiddenValue) {
s.options[i].selected = true;
break;
}
}
}
onsomeformevent="getValue(this.form,'foo','bar')"

Cheers Mark

On Monday, October 20, 2003, at 07:55 AM, Jacob Wilson wrote:

Thanks Matt... It sure helped...

Actually, now, I tried to put it as a common function like...

function getValue(optionName, hiddenValue) {
var s = document.forms[0].optionName;
for (var i=0; i> if ( s.options[i].value == hiddenValue ) {
s.options[i].selected = true;
break;
}
}
}
where optionName is the name of the selectboxes that r in the form --
when I try to use 'optionName' it throws an error when I try to get
the length saying option is null... Am I missing something here???
Please let me know... Thanks in advance...

-Jacob

"Kruse, Matt" wrote:
This is a basic question... Can I find the index of a select box,
if I have the value or the text ???
document.formName.optionName.options["C"].selected=true
-- This won't work!!
You need to loop through each option, checking to see it's value and
then
checking it.
var s = document.formname.optionname;
for (var i=0; i if (s.options[i].value=="C") {
s.selected=true;
}
}
Or, using functions at
http://www.mattkruse.com/javascript/validations/ you
can do:
setInputValue(document.formname.optionname,"C");

Be careful - multiple options are allowed to have the same value!

Matt Kruse



-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [ot] Re: question on javascript...

2003-10-20 Thread Mark Lowe
Its been a while..

try the index or hardcode the form name like before in case it doesn't 
like the form object being passed as an argument...

function getValue(formName,elementName,value) {
s = document.forms[formName].elements[elementName];
..
Cheers Mark

On Monday, October 20, 2003, at 02:55 PM, Jacob Wilson wrote:

Thanks for the help Mark... when I do this, it says 
elements.optionName is not null or an object... Any clue??? Thanks!

Mark Lowe <[EMAIL PROTECTED]> wrote:Those variable don't really 
need to be global.

function getValue(form, optionName,hiddenValue) {
s = form.elements[optionName];
for(i = 0;i < s.options.length;i++) {
if(s.options[i].value == hiddenValue) {
s.options[i].selected = true;
break;
}
}
}
onsomeformevent="getValue(this.form,'foo','bar')"

Cheers Mark

On Monday, October 20, 2003, at 07:55 AM, Jacob Wilson wrote:

Thanks Matt... It sure helped...

Actually, now, I tried to put it as a common function like...

function getValue(optionName, hiddenValue) {
var s = document.forms[0].optionName;
for (var i=0; i> if ( s.options[i].value == hiddenValue ) {
s.options[i].selected = true;
break;
}
}
}
where optionName is the name of the selectboxes that r in the form --
when I try to use 'optionName' it throws an error when I try to get
the length saying option is null... Am I missing something here???
Please let me know... Thanks in advance...

-Jacob

"Kruse, Matt" wrote:
This is a basic question... Can I find the index of a select box,
if I have the value or the text ???
document.formName.optionName.options["C"].selected=true
-- This won't work!!
You need to loop through each option, checking to see it's value and
then
checking it.
var s = document.formname.optionname;
for (var i=0; i if (s.options[i].value=="C") {
s.selected=true;
}
}
Or, using functions at
http://www.mattkruse.com/javascript/validations/ you
can do:
setInputValue(document.formname.optionname,"C");

Be careful - multiple options are allowed to have the same value!

Matt Kruse



-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [ot] Re: question on javascript...

2003-10-20 Thread Jeff Kyser
form.elements is an array, and you'd have to specify
it by index:
	s = form.elements[i];

where i was a supplied integer in the range 0..form.elements.length-1, 
or

	s = form.optionName;

if 'optionName' was a valid name for a form element.

HTH,

-jeff

On Monday, October 20, 2003, at 08:55  AM, Jacob Wilson wrote:

Thanks for the help Mark... when I do this, it says 
elements.optionName is not null or an object... Any clue??? Thanks!

Mark Lowe <[EMAIL PROTECTED]> wrote:Those variable don't really 
need to be global.

function getValue(form, optionName,hiddenValue) {
s = form.elements[optionName];
for(i = 0;i < s.options.length;i++) {
if(s.options[i].value == hiddenValue) {
s.options[i].selected = true;
break;
}
}
}
onsomeformevent="getValue(this.form,'foo','bar')"

Cheers Mark

On Monday, October 20, 2003, at 07:55 AM, Jacob Wilson wrote:

Thanks Matt... It sure helped...

Actually, now, I tried to put it as a common function like...

function getValue(optionName, hiddenValue) {
var s = document.forms[0].optionName;
for (var i=0; i> if ( s.options[i].value == hiddenValue ) {
s.options[i].selected = true;
break;
}
}
}
where optionName is the name of the selectboxes that r in the form --
when I try to use 'optionName' it throws an error when I try to get
the length saying option is null... Am I missing something here???
Please let me know... Thanks in advance...

-Jacob

"Kruse, Matt" wrote:
This is a basic question... Can I find the index of a select box,
if I have the value or the text ???
document.formName.optionName.options["C"].selected=true
-- This won't work!!
You need to loop through each option, checking to see it's value and
then
checking it.
var s = document.formname.optionname;
for (var i=0; i if (s.options[i].value=="C") {
s.selected=true;
}
}
Or, using functions at
http://www.mattkruse.com/javascript/validations/ you
can do:
setInputValue(document.formname.optionname,"C");

Be careful - multiple options are allowed to have the same value!

Matt Kruse



-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: [ot] Re: question on javascript...

2003-10-20 Thread Jacob Wilson
Thanks for the help Mark... when I do this, it says elements.optionName is not null or 
an object... Any clue??? Thanks!

Mark Lowe <[EMAIL PROTECTED]> wrote:Those variable don't really need to be global.

function getValue(form, optionName,hiddenValue) {
s = form.elements[optionName];
for(i = 0;i < s.options.length;i++) {
if(s.options[i].value == hiddenValue) {
s.options[i].selected = true;
break;
}
}
}

onsomeformevent="getValue(this.form,'foo','bar')"

Cheers Mark

On Monday, October 20, 2003, at 07:55 AM, Jacob Wilson wrote:

> Thanks Matt... It sure helped...
>
> Actually, now, I tried to put it as a common function like...
>
> function getValue(optionName, hiddenValue) {
> var s = document.forms[0].optionName;
> for (var i=0; i> if ( s.options[i].value == hiddenValue ) {
> s.options[i].selected = true;
> break;
> }
> }
> }
>
> where optionName is the name of the selectboxes that r in the form -- 
> when I try to use 'optionName' it throws an error when I try to get 
> the length saying option is null... Am I missing something here???
>
> Please let me know... Thanks in advance...
>
> -Jacob
>
> "Kruse, Matt" wrote:
>> This is a basic question... Can I find the index of a select box,
>> if I have the value or the text ???
>> document.formName.optionName.options["C"].selected=true
>> -- This won't work!!
>
> You need to loop through each option, checking to see it's value and 
> then
> checking it.
>
> var s = document.formname.optionname;
> for (var i=0; i if (s.options[i].value=="C") {
> s.selected=true;
> }
> }
>
> Or, using functions at 
> http://www.mattkruse.com/javascript/validations/ you
> can do:
>
> setInputValue(document.formname.optionname,"C");
>
> Be careful - multiple options are allowed to have the same value!
>
> Matt Kruse
>
>
>
>
> -
> Do you Yahoo!?
> The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search

[ot] Re: question on javascript...

2003-10-20 Thread Mark Lowe
Those variable don't really need to be global.

function getValue(form, optionName,hiddenValue) {
s = form.elements[optionName];
for(i = 0;i < s.options.length;i++) {
if(s.options[i].value == hiddenValue) {
s.options[i].selected = true;
break;
}
}
}
onsomeformevent="getValue(this.form,'foo','bar')"

Cheers Mark

On Monday, October 20, 2003, at 07:55 AM, Jacob Wilson wrote:

Thanks Matt... It sure helped...

Actually, now, I tried to put it as a common function like...

function getValue(optionName, hiddenValue) {
   var s = document.forms[0].optionName;
   for (var i=0; i
where optionName is the name of the selectboxes that r in the form -- 
when I try to use 'optionName' it throws an error when I try to get 
the length saying option is null... Am I missing something here???

Please let me know... Thanks in advance...

-Jacob

"Kruse, Matt" <[EMAIL PROTECTED]> wrote:
This is a basic question... Can I find the index of a select box,
if I have the value or the text ???
document.formName.optionName.options["C"].selected=true
-- This won't work!!
You need to loop through each option, checking to see it's value and 
then
checking it.

var s = document.formname.optionname;
for (var i=0; i if (s.options[i].value=="C") {
s.selected=true;
}
}
Or, using functions at 
http://www.mattkruse.com/javascript/validations/ you
can do:

setInputValue(document.formname.optionname,"C");

Be careful - multiple options are allowed to have the same value!

Matt Kruse



-
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]