SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Posts
    46
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need help on coding for this textbox

    I have a function below where every time a question is submitted, it will add a new row in the table with a textbox which allows numbers entry only. My question is that I don't know how to code these features in this function:

    1: I want the text box to be between 0 and 100, so if text box contains a number which is above 100, it will automatically change the number to the maximum number which is 100.

    Does any one know how to code this in my function below in javascript:

    Code:
    function insertQuestion(form) 
        {   
        
             var row = document.createElement("tr");
             var cell, input;
        
        cell = document.createElement("td");
             cell.className = "weight";
             input = document.createElement("input");
             input.name = "weight_" + qnum;
             input.onkeypress = "return isNumberKey(event)";
             cell.appendChild(input);
             row.appendChild(cell);
        }

  2. #2
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't think you actually wrote the code you posted because if you did, then you would know that the code you are asking for needs to go into your onkeypress event handler and not the function you posted.


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
  •