0

I have code :

<td><input type="hidden" id="someText" name="someText" value="Hello World!">  </td>
<td><button onclick="test(document.getElementById('someText'))">Invoke Some</button></td>

I want to pass someText to my test() . But I get [object HTMLInputElement]. I must pass it in html no in

1
  • what do you need to send? complete the question Commented May 3, 2016 at 11:38

2 Answers 2

4

You are passing the Element Object, you need to access its value

<td><button onclick="test(document.getElementById('someText').value)">Invoke Some</button></td>

Replaced

test(document.getElementById('someText'))

with

test(document.getElementById('someText').value)
Sign up to request clarification or add additional context in comments.

Comments

1

Use the id of the div to get the value in it and pass it to the function.

<input type="hidden" id="someText" name="someText" value="Hello World!">  </td>
<td>
    <button onclick="test(document.getElementById('id of your div').value)">Invoke Some</button>
</td>

Comments

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.