I am trying to write an iPhone app and on one of my pages and I want to capture the form data and then using the onclick event to pass the values to a JavaScript function which will open the SMS window.
The onclick
event below passes txt1
and txt2
to the JavaScript function and works perfectly.
<input onclick="window.plugins.smsComposer.showSMSComposer('txt1', txt2');" type="button" value="Send Reboot Command Via SMS" />
However, I need to replace txt1
and txt2
with the actual values the user enters in the form.
The following is the code for the page hope it assist to understand what I am trying to achieve.
function updateTxt(field,toField){
var field = document.getElementById(field);
var toField = document.getElementById(toField);
toField.innerHTML=field.value;
}
<div data-role="page" id="DevicesConfigurePage" data-add-back-btn="true">
<div data-role="header" id="myheader" data-position="fixed">
<h1>Reeboot</h1>
</div>
<br>
<input type="text" id="box1" onkeyup="updateTxt('box1','txt1');"><br>
<input type="text" id="box2" onkeyup="updateTxt('box2','txt2');"><br>
<input type="text" id="box3" onkeyup="updateTxt('box3','txt3');"><br>
<input type="text" id="box4" onkeyup="updateTxt('box4','txt4');"><br>
<input onclick="window.plugins.smsComposer.showSMSComposer(id="txt1", id="txt2");" type="button" value="Send Reboot Command Via SMS" /><br /> <br>
<!-- /content -->
<p class="copyright">Copyright © TrackingCentral Pty Ltd</p>
</div><!-- /page -->
I don't see any relation between the jQuery and HTML code you provided. (Before you eidt your post further). I think you want to place a specific value in some specific region. You may try this.
$('#toField').html(field.value);
Instead of
toField.innerHTML=field.value;
and also fix this:
var field = document.getElementById('field');
var toField = document.getElementById('toField');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.