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")'>
<开发者_如何学JAVA;input type=button id="callendbutton4" class="hangup" value='Hangup' onClick='voipHangup()'>
Is there an easy way to do this?
Thanks for any help
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;
You can use javascript to get the text from your phonenumber input text field.
jquery: voipCall($("#phonenumber").val())
Call that voipCall() in the voiphangup().
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.
精彩评论