I would like to display what is in the texbox in the alert message below.
alert("You have selected: " + cbotherstext);
<input id="cbotherstext" type="text" /></td>
Thanks so much.
Try this with jquery :
alert("You have selected: " + $("#cbotherstext").val());
<input id="cbotherstext" type="text" />
you also need something that call the function eg (with Jquery)
<input id="cbotherstext" type="text" />
<a id="example">Example</a>
<script>
$("#example").click(function(){
alert("You have selected: " + $("#cbotherstext").val());
});
</script>
without Jquery
<input type="text" id="cbotherstext" >
<a onclick="alert_val()"> click me</a>
<script> function alert_val(){
alert("You have selected: " + document.getElementById('cbotherstext').value);
}</script>
This is how to do it:
alert("You have selected: " + document.getElementById("cbotherstext").value);
<input id="cbotherstext" type="text" /></td>
Try this
HTML
<input id="cbotherstext" type="text" />
Script
$("#cbotherstext").keyup(function(){
alert("You have selected: " + $("#cbotherstext").val());
});
Fiddle
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.