Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Generating content with JS, IE problem

edited December 2006 in Vanilla 1.0 Help
Hi again, folks.. in the Vanilla forum you can add custom labels and values in your account information. You simply click a link, and html is generated automatically. I have made the same thing, but it works only in FF (etc). It does not in IE!. Here is the code.
function addprod() { var tot_prod=document.getElementById('total'); var thetable=document.getElementById('addprod'); if (tot_prod && thetable) { tot_prod.value++; var tr= document.createElement('tr'); var td1= document.createElement('td'); var td2= document.createElement('td'); var td3= document.createElement('td'); var td4= document.createElement('td'); var input1=document.createElement('input'); input1.type='text'; input1.name='code_'+tot_prod.value; input1.size='10'; var input2=document.createElement('input'); input2.type='text'; input2.name='title_'+tot_prod.value; input2.size='50'; var input3=document.createElement('input'); input3.type='text'; input3.name='quan_'+tot_prod.value; input3.size='2'; var input4=document.createElement('input'); input4.type='text'; input4.name='price_'+tot_prod.value; input4.size='6'; td1.appendChild(input1); td2.appendChild(input2); td3.appendChild(input3); td4.appendChild(input4); tr.appendChild(td1); tr.appendChild(td2); tr.appendChild(td3); tr.appendChild(td4); thetable.appendChild(tr); } }
Any ideas?

thanks

Comments

  • solved.... thanks... forget about it.... admins, remove this discussion if you have time.. thanks
  • In the future, you might consider using the Scriptaculous/Prototype libraries already packaged with Vanilla... They're usually tested on all browser platforms, so it's a bit safer...
  • thanks.... but i solved the problem myself already... the problem was that IE only accepted certain additional parameters for generated inputs... here is the script that works in eny browser (tested on ff, ie, and opera)..

    /* adding products */ function addprod() { var tot_adds=document.getElementById('tot_adds'); var thetable=document.getElementById('addprod'); if (navigator.appName=='Microsoft Internet Explorer') { if (tot_adds && thetable) { tot_adds.value++; var tr= document.createElement("TR"); var td1= document.createElement("TD"); var td2= document.createElement("TD"); var td3= document.createElement("TD"); var td4= document.createElement("TD"); var input1=document.createElement('<input type="text" name="code_a_'+tot_adds.value+'" size="10" />'); var input2=document.createElement('<input type="text" name="title_a_'+tot_adds.value+'" size="50" />'); var input3=document.createElement('<input type="text" name="quan_a_'+tot_adds.value+'" size="2" />'); var input4=document.createElement('<input type="text" name="price_a_'+tot_adds.value+'" size="6" />'); td1.appendChild(input1); td2.appendChild(input2); td3.appendChild(input3); td4.appendChild(input4); tr.appendChild(td1); tr.appendChild(td2); tr.appendChild(td3); tr.appendChild(td4); thetable.appendChild(tr); /*alert(thetable.innerHTML+';'+tot_adds.value);*/ } } else { if (tot_adds && thetable) { tot_adds.value++; var tr= document.createElement("TR"); var td1= document.createElement("TD"); var td2= document.createElement("TD"); var td3= document.createElement("TD"); var td4= document.createElement("TD"); var input1=document.createElement("INPUT"); input1.type='text'; input1.name='code_a_'+tot_adds.value; input1.size='10'; var input2=document.createElement("INPUT"); input2.type='text'; input2.name='title_a_'+tot_adds.value; input2.size='50'; var input3=document.createElement("INPUT"); input3.type='text'; input3.name='quan_a_'+tot_adds.value; input3.size='2'; var input4=document.createElement("INPUT"); input4.type='text'; input4.name='price_a_'+tot_adds.value; input4.size='6'; td1.appendChild(input1); td2.appendChild(input2); td3.appendChild(input3); td4.appendChild(input4); tr.appendChild(td1); tr.appendChild(td2); tr.appendChild(td3); tr.appendChild(td4); thetable.appendChild(tr); } } }
This discussion has been closed.