#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    29
    Rep Power
    0

    InnerHTML doesn work on internet explorer


    Hi to all. I have a task wich i show you in the end of message.
    My problem is coming from innerHTML.
    Under firefox and chrome everything is OK but when i start it under IE7 and above nothing happend.
    This is my code :
    this is in JS file:

    function validate(param) {

    if(param.length >=3) { ////show the parameter and check it for minimal lenght in the entry of the text field
    var regex = /^(\d+)\-(\d+)$/i; // create regular expression that we use for our purposes
    //var regex = /(\d+)(\.(\d+))*(\/(\d+))*-(\d+)$/ ;

    var match = regex.exec(param);
    if(match !== null) { //check if we have a coincidence
    var select = generateSelecte(match[1], match[2]); //call the function with the two elemets, two numbers
    if(select !== false) { //if we have some result
    document.getElementById("mineSelect"). innerHTML = select; //in DOM we put the checkd result
    }
    }
    else {
    alert('The use value "'+param+'" is not valid');
    }
    }
    else {
    return false;
    }
    }



    this is in HTML file
    <html>
    <head>
    <title></title>
    <script type="text/javascript" src="general.js"></script>

    </head>
    <body>

    <div id="masterParent">

    <div id="message"></div>
    <form>

    <input style="width:200px; height: 35px; line-height: 35px; color: green; border-radius: 3px; border: 1px solid silver;" type="text" id="inputText" name="cifri" placeholder="Please fill with mask 'dd-dd'" />
    <span id='select'>
    <select name="select4e" id="mineSelect">
    <option>Please fill the require field</option>
    </select>
    </span>
    <!-- When you click the button, he trigger onClick and call function 'validate' and take the result in tekst field -->
    <input type="button" name="button" value="validate and set" onclick="validate(document.getElementById('inputText').value)" />
    </form>
    </div>

    </body>
    </html>
  2. #2
  3. CSS & JS/DOM Adept
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2004
    Location
    USA (verifiably)
    Posts
    20,122
    Rep Power
    4258
    innnerHTML can be useful for somethings, but when working with forms it's best to avoid it.

    Please post your "generateSelecte" function.
    Spreading knowledge, one newbie at a time.

    Check out my blog. | Learn CSS. | PHP includes | X/HTML Validator | CSS validator | Common CSS Mistakes | Common JS Mistakes

    Remember people spend most of their time on other people's sites (so don't violate web design conventions).
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2013
    Posts
    29
    Rep Power
    0

    here it is my generateSelecte function


    function generateSelecte(el1 , el2) {
    el1 = parseInt(el1);
    el2 = parseInt(el2);
    var DOMselect = ''; // empty string
    if(el1 < el2) { //when first number is lower we have positiv incrementation
    for(var k = el1; k <= el2; k++) {
    DOMselect = DOMselect + '<option value='+k+'>'+k+'</option>'; // на всеки елемент добавяме нов елемент оптионс за всяко въртене на цикъла
    }//on every element we add new options for every rotation in to the LOOP
    return DOMselect;
    }
    else if(el1 > el2) {
    for(var k = el1; k >= el2; k--) { //negative, subtrac 1
    DOMselect = DOMselect + '<option value='+k+'>'+k+'</option>';
    }
    return DOMselect;
    }
    else {
    return false;
    }
    }

IMN logo majestic logo threadwatch logo seochat tools logo