Revos Posted August 31, 2006 Share Posted August 31, 2006 Hello.I got button called XX how can I make that when I press the button, the value of text box named XY will change to "444"? Quote Link to comment Share on other sites More sharing options...
trq Posted August 31, 2006 Share Posted August 31, 2006 Use the onClick event to fire off a function like...[code]function changer() { document.form.XY.value = "444";}[/code] Quote Link to comment Share on other sites More sharing options...
Revos Posted August 31, 2006 Author Share Posted August 31, 2006 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.. Quote Link to comment Share on other sites More sharing options...
trq Posted August 31, 2006 Share Posted August 31, 2006 You dont have any form in your document and your synatx is slightly off....[code]<input name="Button1" type="button" value="Bla" onClick='Document.form.Txt.value = "444";' />[/code] Quote Link to comment Share on other sites More sharing options...
syed Posted August 31, 2006 Share Posted August 31, 2006 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> Quote Link to comment Share on other sites More sharing options...
radalin Posted September 1, 2006 Share Posted September 1, 2006 if you define the js code in onclick part and not point it to a js function just like this:[code]<input type="button" value="click me" onClick="text1.value='test message'">[/code]and it will work fine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.