0

i want to pass the udid taken from textfield to function getusername.

<tr>
     <td> Enter Udid : </td>
     <td> <input name="udid" id="udid" type="text" value="{{udid}}" size="50"></td>
</tr>

<td> 
     <input type="button" value="Get User Name(udid)" onclick="getUserName(udid);"> 
</td>
1
  • I am not really a pro in javascript, but i think you should pass id of the element, since u are initializing id=udid. Commented Sep 13, 2012 at 7:31

2 Answers 2

3

This should work:

onclick="getUserName(document.getElementById('udid').value);"
Sign up to request clarification or add additional context in comments.

Comments

1

Try this code:

In your html:

<input type="button" value="Get User Name(udid)" onclick="getUserName(document.getElementById('udid'));">

Function javascript:

function getUserName(id){
    alert(id.value);
}

Look at this demo: JSFIDDLE

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.