General discussion

Locked

parameters usage in javascript

By Arati ·
i am stuck with an situation i give the code here.
parameters sent from function is working in alert nicely but it is not woring in if condition (document.f1.cmb....)



<script>
function checkcmb(x)
{
var i = x
alert("recmb"+);
//alert("recmb" + (parseInt(i)));
if (document.f3.(recmb+).selectedIndex)==1)
(document.f3.(noofret+).blur();
}
</script>
kindly study & help me out.

regards

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

parameters usage in javascript

by Shanghai Sam In reply to parameters usage in javas ...

It appears you're trying to check the value of a SELECT element, then removing focus from some other element based on the value. This seems strang to me, but I'm sure you have a higher purpose in mind...

Anyway, it looks like your parentheses aremismatched on a couple of lines, and you're trying to access a string as if it were and object. Try this:

function checkcmb(i)
{
var element1 = eval('document.f3.recmb' + i);
var element2 = eval('document.f3.noofret' + i);
if (element1.selectedIndex == 1)
element2.blur();
}

I used the eval function to convert the constructed string to an object reference for each element. One final note: the selectedIndex attribute is zero-based. Your code actually looks for the second item in the list (index 1).

Hope this helps.

Collapse -

parameters usage in javascript

by Arati In reply to parameters usage in javas ...

Poster rated this answer

Collapse -

parameters usage in javascript

by Arati In reply to parameters usage in javas ...

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums