0

Is it possible to send multiple element from inline javascript onclick function for example like this i tried but got undefined

<input type='text' id='elem1'/>
<input type='text' id='elem2'/>
    <a onclick="functionName($('#elem1').val(),$('#elem2').val())"></a>

?

Younis Qadir
  • 315
  • 1
  • 4
  • 16

2 Answers2

2

You can try this

<input type='text' id='elem1'/>
<input type='text' id='elem2'/>
<a onclick="myfunc($('#elem1').val(),$('#elem2').val())"></a>

Javascript

function myfunc(val1,val2)
{
  alert(val1);
  alert(val1);
}
Mairaj Ahmad
  • 14,434
  • 2
  • 26
  • 40
1

Is it a shared function? Why not just access the values from inside the actual function?

nite
  • 186
  • 1
  • 2
  • 8
  • the function is called from many parts and the value of elem1 and elem2 is from some different elements this is why i tried this. and i also wandered if it is possible to do like this or not because i searched i didn't get any results. :) – Younis Qadir Jun 13 '16 at 07:28