Jump to content

Inserting any value into a text box by clicking a button - how?


Revos

Recommended Posts

I tried this code:
[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document</title>
</head>
<input name="Txt" type="text" value="123" />
<input name="Button1" type="button" value="Bla" onClick= "Document.form.Txt.value = "444" />
<body>
</body>
</html>[/code]
but it doesn't work..
As thorpe said you need to create a form tag such as <form name="form1"> all your form objects must go between the form opening and closing tags.

example

<form name="form1">
<input type="text" name="text1" size="20">
<input type="button" value="click me" onClick="document.form1.text1.value='test message'">
</form>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.