• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

textbox value to an alert on click

hi

I want  a value from a html text box to appear in an alert when clicking a button. I think I need to do this using javascript. does any one have an example I can use please?

thanks
0
ac_davis2002
Asked:
ac_davis2002
  • 2
3 Solutions
 
a_bCommented:
Check the onclick section of this page - http://www.intranetjournal.com/corner/hoque/eh-1.shtml
0
 
silemoneCommented:
yes, you need javascript....

onclick of a button do this:

function theClick(){
var ele = document.getElementById("txtBoxID");
alert (ele.value);

}
0
 
silemoneCommented:
<input type="button" onclick="theClick">
<input type="text" id="txtBoxID" name ="txtBoxID">...

to conclude my example...

<script type="text/javascript">
       function theClick(){
var ele = document.getElementById("txtBoxID");
alert (ele.value);

}
</script>
0
 
LordZardeckCommented:
Silemone, don't you have to place () with the function in the onclick attribute? Like this?:

<input type="button" onclick="theClick()" />
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now