2ji8888 Posted July 17, 2008 Share Posted July 17, 2008 my friend made this for me, it aint working... <html><head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > <title>Test</title> <link rel="stylesheet" type="text/css" href="css/style.css"><STYLE type="text/css">#mnuNextcall { font-family: verdana; font-size: 10px;}</style><script src="js/script.js">var menu = document.getElementById('menu');menu.elements['mnuNextcall'].onclick = function () { this.form.elements['txtCallCntr'].value++;}</script></head><body><form id="menu" action="process.php"> <p><input type="text" name="txtCallCntr" value="0" disabled="disabled"></p> <p><input type="button" name="mnuNextcall" value="Start Next Call"></p></form></body></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted July 17, 2008 Share Posted July 17, 2008 I think you should duct-tape your friend to a bed and beat him about the head and shoulders with a bar of soap in a gym sock. That will teach him to write bad code. Link to comment Share on other sites More sharing options...
jeffman Posted July 18, 2008 Share Posted July 18, 2008 Now take some time to study all the little changes I made. Some items in the script may seem unnecessary (as in, there are shortcuts) but get in the habit of doing things the right way and you'll never go wrong. (Most of the time, you spend more time editing code than writing it, so shortcuts are useless.) For the text element, I chose "readonly" over "disabled" because "disabled" is often rendered in light gray and hard to read. You probably wouldn't use a text element there anyway, but let's make it readable if we do. (And don't blame me if this doesn't copy and paste well. That happens a lot.) <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html> <head> <meta http-equiv="content-type" content="text/html;charset=iso-8859-1"> <title>Test</title> <link rel="stylesheet" type="text/css" href="css/style.css"> <style type="text/css"> #mnuNextcall { font-family: verdana; font-size: 10px; } </style> <script type="text/javascript"> function bump () { document.getElementById('myText').value++; } function init () { document.getElementById('myButton').onclick = bump; } window.onload = init; </script> </head> <body> <form id="menu" action="process.php"> <p><input type="text" name="txtCallCntr" value="0" readonly="readonly" id="myText"></p> <p><input type="button" name="mnuNextcall" value="Start Next Call" id="myButton"></p> </form> </body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.