...

View Full Version : argument declaration in form1.arg.focus();



Jerome
07-13-2003, 10:10 AM
Hi,

How can I put the argument - arg - in - form1.arg.focus(); - that it works?

the value of arg = the name of an input-field
form1 = the name of the form in which the input-field is located

function func(arg)
{
form1.arg.focus();
}

Thanks,
Jerome

Graeme Hackston
07-13-2003, 03:47 PM
I'm not sure if I understand your question

<script>

function func(arg)
{
document.form1.arg.focus()
}

</script>
<form name="form1">
<input name="arg">
</form>
<input type="button" onclick="func('arg')">

<edit>
opps, doesn't work if you change arg to something else. I'll check further
</edit>

Graeme Hackston
07-13-2003, 03:56 PM
ok, brain fade. Here you go

<script>

function func(arg)
{
document.form1[arg].focus();
}

</script>
<form name="form1">
<input name="arg1">
</form>
<input type="button" onclick="func('arg1')">

Jerome
07-13-2003, 04:24 PM
Works perfect, thanks Graeme

I was a little confused, I wrote:

form1.arg.focus();

however it had to be:

form1[arg].focus();

Nice week-end!
Jerome



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum