Note that there are some explanatory texts on larger screens.

plurals
  1. POError in IE when looping
    primarykey
    data
    text
    <p>Lets clarify my question,</p> <p>I want to make an element which the element contains 5 fields so I dont want the user should be able to put in a new element if the old one is null, so I made the alert when looping through the old element and see if there is some strings, if not then dont put a new element and make an alert please fill out all fields</p> <p>Here again my code</p> <pre><code>function addEvent() { var ni = document.getElementById('discount'); // Takes the a div named discount var discountForm = document.getElementById('discountForm'); // Takes the a form named discountForm var numi = document.getElementById('theValue'); // Takes the a hidden input field named theValue var num = (document.getElementById("theValue").value -1)+ 2; // Start counting to set the new divs form numbers numi.value = num; var divIdName = "my"+num+"Div"; // the new divs will be named var allDivTags = discountForm.getElementsByTagName('div'); // take all div tags var numOfDivs = (allDivTags.length -1); // take the number of the old div var oldDivIdName = document.getElementById(allDivTags[numOfDivs].id); // old div id var newdiv = document.createElement('div'); //the new div newdiv.setAttribute("id",divIdName); newdiv.innerHTML = "Company &lt;select name=\"company[]\"&gt;&lt;option value=\"\"&gt;&lt;/option&gt;&lt;option value=\"ZI\"&gt;Avis&lt;/option&gt;&lt;option value=\"ET\"&gt;Enterprise&lt;/option&gt;&lt;option value=\"ZE\"&gt;Hertz&lt;/option&gt;&lt;option value=\"ZD\"&gt;Budget&lt;/option&gt;&lt;option value=\"ZR\"&gt;National&lt;/option&gt;&lt;option value=\"AL\"&gt;Alamo&lt;/option&gt;&lt;/select&gt; Discount Type &lt;select name=\"type[]\"&gt;&lt;option value=\"CD\"&gt;Discount Number&lt;/option&gt;&lt;option value=\"PC\"&gt;Coupon Number&lt;/option&gt;&lt;/select&gt; Code &lt;input name=\"code[]\" type=\"text\"&gt; Title &lt;input name=\"title[]\" type=\"text\"&gt; &lt;a href=\"javascript:;\" onclick=\"removeElement(\'"+divIdName+"\')\"&gt;Remove&lt;/a&gt;"; // creating the fileds in the new div ni.appendChild(newdiv); for(i=0; i&lt;discountForm.elements.length;i++){ // loop through the divs if(numOfDivs != i-1){ // if tho old div exist and if the old div fields are empty if(oldDivIdName.children[i].value.length == 0){ removeElement(divIdName); // then dont put the new one alert('Please enter all fields'); } } } } </code></pre> <p>But my problem is that in IE comes out an error <code>children[...].value.length is null or not an object</code> so I trying to figure how to fix it,</p> <p>I hope its more clearly for you now.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload