0

I am currently using this code:

<input type=button value='Call' class="call" onClick='voipCall("<?php echo $number_1;?>")'>
<input type=button id="callendbutton" class="hangup" value='Hangup' onClick='voipHangup()'>

which uses the variable $number_1 and passes it into a javascript function to call that number. Now I need another section which lets the user input their own number to call, but I'm not sure how to pass the information from the text input box into the function call.

Something like this:

<input type="text" tip="Enter alternate phone number" name="phonenumber" id="phonenumber" size="40" value=""/>
<input type=button value='Call' class="call" onClick='voipCall("#phonenumber")'>
<input type=button id="callendbutton4" class="hangup" value='Hangup' onClick='voipHangup()'>

Is there an easy way to do this?

Thanks for any help

1
  • Is function a javascript or Php? Commented May 9, 2011 at 12:42

4 Answers 4

2

You can use the id "phonenumber" to fetch the text-input node, and then get the current value from it:

var number = document.getElementById('phonenumber').value;
Sign up to request clarification or add additional context in comments.

2 Comments

HTMLElementNodes don't have a val method.
Thanks for your help Adrian, I used Garth's solution in the end but I'll keep a record of yours too
0

You can use javascript to get the text from your phonenumber input text field.

jquery: voipCall($("#phonenumber").val())

Comments

0

Call that voipCall() in the voiphangup().

Comments

0

Use 'title' instead of 'tip'.
Use document.getElementById('phonenumber') to access the input field and get its value.
You can set a variable with default set by PHP if you want, getting the input field value if non empty, and use this variable in your JavaScript call.

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.