form=document.request_form; function builds_add() { var tbody=document.getElementById('id_builds_additional'); var row=document.createElement('TR'); var cell_title=document.createElement('TD'); var cell_delimeter_1=document.createElement('TD'); var cell_square=document.createElement('TD'); var cell_delimeter_2=document.createElement('TD'); var cell_cost=document.createElement('TD'); row.appendChild(cell_title); row.appendChild(cell_delimeter_1); row.appendChild(cell_square); row.appendChild(cell_delimeter_2); row.appendChild(cell_cost); cell_title.className='constrName'; cell_square.className='constSpace'; cell_cost.className='constrAmmount'; cell_delimeter_1.className='brace'; cell_delimeter_2.className='brace'; /*Создаем инпут названия постройки*/ var inp=document.createElement('INPUT'); inp.type='text'; inp.name='b_add_title['+tbody.rows.length+']'; inp.onkeypress=builds_try_add; cell_title.appendChild(inp); var inp=document.createElement('INPUT'); inp.type='text'; inp.name='b_add_square['+tbody.rows.length+']'; inp.onkeypress=builds_try_add; inp.onblur=function () { this.value=this.value.replace(/\,/g,'.'); this.value=this.value.replace(/[^0-9\.]+/g,''); } cell_square.appendChild(inp); var inp=document.createElement('INPUT'); inp.type='text'; inp.name='b_add_cost['+tbody.rows.length+']'; inp.onkeypress=builds_try_add; cell_cost.appendChild(inp); tbody.appendChild(row); } function builds_try_add() { var tbody=document.getElementById('id_builds_additional'); var reg=/\[(\d+)\]/; var text=reg.exec(this.name); if (text[1]*1==tbody.rows.length-1) builds_add(); } builds_add(); function show_cost(obj,idx) { if (obj.checked) { document.getElementById('obj'+idx+'_block').style.display=''; document.getElementById('labelBlock').style.display=''; }else { document.getElementById('obj'+idx+'_block').style.display='none'; if (!form.what_1.checked && !form.what_2.checked && !form.what_3.checked && !form.what_5.checked) document.getElementById('labelBlock').style.display='none'; } }