Click to See Complete Forum and Search --> : Diffentiate buttons


tama
07-14-2003, 07:35 AM
Hi!
I'm a novice of Javascript, and I have this problem

I have a form with 2 textareas for inserting a date and 3 button (Adding, Refine, Cancel).

After having checked the correct format for both dates, I need to differentiate the buttons Adding and Refine for calling two differents java methods in a controller depending on the clicked button...

What can I do?

Thanks

Marco

Gollum
07-14-2003, 08:11 AM
Not quite sure what you mean here.

Each button has its own onclick handler in which you can put different code to do different things...

<input type=button value="Add" onclick="CallJavaAdd();">
<input type=button value="Refine" onclick="CallJavaRefine();">
<input type=button value="Cancel" onclick="LetsCallTheWholeThingOff();">

Does this help?

requestcode
07-14-2003, 08:11 AM
If you are using the onClick event in each button to perform the function then you could place "this.value" in the function call and then in the function check to see what was passed.

<input type="button" value="Adding" onClick="myfunc(this.value)">

function myfunc(button_val)
{
if(button_val=="Adding")
{do something}
if(button_val=="Refine")
{do something}

}

tama
07-14-2003, 08:13 AM
thanks a lot for helping!
Now it's right!