Jump to content

Function to write value


vytas

Recommended Posts

I have a textbox , and i have a javascript that gets the value of that textbox and writes it down.But everytime the function is called the textbox disapears .I think i need to use the return but i don't now how.

<html><head><title>h</title></head><body><script type="text/javascript">function getValue(){  var r = document.getElementById('field1').value  return (r)  }</script><br><input type="text"value="hallo"name="field1"onblur="getValue()">hallo</body></html>

Hope some1 can sort this one out.

Link to comment
Share on other sites

I don't get what you are doing... ?Like print the input value on the site?(You need the input to be close... <input />)

Link to comment
Share on other sites

Well closing it with / is only in XHTML .I want to print the value of the textbox on the page ,without the textbox disapearing.

Link to comment
Share on other sites

You might try this:

<script type="text/javascript">function getValue(){	var r = document.getElementById('field1').value	document.getElementById("TextValue").innerHTML = r;}</script><div id="TextValue"></div><input type="text"value="hallo"name="field1" onblur="getValue();" />

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...