Javascript and JSP

Here is my dilemna:

I have a textbox, dynamically named '227' and another textbox, dynamically named '227_units'

named form a <% String output=blah.blah.m_sName %>

name=<%=output%>

type of arrangement.

All is fine.

now, in my Input Box:

<input type=text name=<%=blahblah%> onBlur="calculate(this)">

When I actually want to pass the second textbox in as well:

<input type=text name=<%=blahblah%> onBlur="calculate(this,<%=output%>)">

And I of course realize that this will not work...server/client interaction.

How can I pass this second box into my javascript function, or how can I access this box from within the JS function

I tried:

function calculate(input)

{

output= input.name + "_units";

workload_form.output.value=input.value*.25;

}

and it didn't work.....something about workload_form.output is not an object....wasn't sure I could do it anyway.

ANY INPUT IS WELCOMED AND GREATLY APPRECIATED BY A GUY TRYING TO UNDERSTAND AND A DOG THAT BITES HIS LEG!

[1164 byte] By [wmacey] at [2007-9-26 2:10:15]
# 1

One way you could do it is this...

To pass the second input, 227_units, into your calculate function from the first input's, 227, OnBlur event

<input type=text name=<%=blahblah%> onBlur="calculate(this,this.form.227_units)">

this.form gives you a handle to the form that contains the this input, then you can refer to the second input by name

Or you could get a handle to the second input in your calculate function like this

document.<form name>.227_units

or

document.forms[<form index>].227_units

Hope that helps.

I found this to be a very good JavaScript reference, http://developer.netscape.com/docs/manuals/communicator/jsref/index.htm, maybe it will help you in the future.

poopoop at 2007-6-29 9:00:53 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...