Results 1 to 2 of 2

Thread: Script Help

  1. #1
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Script Help

    Hi guys, could you help me on this script that I would like to implement.
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">  
      <head>    
        <title>Some Title     
        </title>    
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />        
      </head>  
      <body>
      <form>
      <fieldset>
      <p><label for="txtCuryear">Academic Year</label><input type="text" name="txtCuryear" id="txtCuryear" /><input type="text" name="txtNxtyear" id="txtNxtyear" /></p>
      </fieldset>
      </form>  
      </body>
      </html>
    there I think I was able to solve it myself lol
    HTML Code:
    <p><label for="txtCuryear">Academic Year</label><input type="text" size="4" maxlength="4" name="txtCuryear" id="txtCuryear" /> - <input type="text" size="4" maxlength="4" name="txtNxtyear" id="txtNxtyear" /></p>
    				<script type="text/javascript">
    					var sID = document.getElementById('txtCuryear');
    					sID.onkeyup = function(event) {
    					  document.getElementById('txtNxtyear').value = parseInt(document.getElementById('txtCuryear').value)+1;
    					}
    				</script>
    I need to display the next year, of the year that is inputted by the user on the current year textbox.

    Your help will be greatly appreciated
    Last edited by comwwwdot; 01-31-2010 at 10:14 AM.

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Try:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <title>
          Some Title 
        </title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type="text/javascript">
           function plus(id, el){
            document.getElementById(id).value = parseInt(el.value) + 1;
          } 
        </script>
      </head>
      <body>
        <form>
          <fieldset>
            <p>
              <label for="txtCuryear">
                Academic Year
              </label>
              <input type="text" name="txtCuryear" id="txtCuryear" />
              <input type="text" name="txtNxtyear" id="txtNxtyear" />
            </p>
          </fieldset>
        </form>
        <script type="text/javascript">
           document.getElementById('txtCuryear').onkeyup = function (){ plus('txtNxtyear', this) }; 
        </script>
      </body>
    </html>
    Last edited by Nile; 01-31-2010 at 03:24 PM.
    Jeremy | jfein.net

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •