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>

?

3
  • Its possible to pass multiple element in javascript onclick function Commented Jun 13, 2016 at 7:02
  • It has been asked in the pass, You can check it. Commented Jun 13, 2016 at 7:06
  • i think my question was not clear but i edited hope you got my mean now :) Commented Jun 13, 2016 at 7:11

2 Answers 2

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);
}
Sign up to request clarification or add additional context in comments.

2 Comments

:) thanks first time i did like this but got undefined but after seeing your answer it works :)
You are welcome i guess you wouldn't have accepted agruments in function that's why got undefined
1

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

1 Comment

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. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.