0

I am using this script to generate a code which will later appear in a form. I have this code working on 2 pages, but I have no idea why it is not able to post to te next page.

Below is my code:

   function add(){



var coun    = document.getElementById('count').value; 

if(coun==""){var count = 1;}
else{var count = (coun*1)+1;}


if(count>=1){
show('cont_del');   
}

var field       = "";
var table       = "";
var desc_arr    = "";
var itn_arr     = "";
var qty_arr     = "";
var cls_arr     = "";
var unp_arr     = "";
var tot_arr     = "";




for(var f=1;f<count;f++){

    desc_arr    = document.getElementById('desc'+f).value;
    itn_arr     = document.getElementById('itn'+f).value;
    qty_arr     = document.getElementById('qty'+f).value;
    <? if($_POST['type']=="o"){ ?>
    cls_arr     = document.getElementById('cls'+f).value;
    <? } ?>
    unp_arr     = document.getElementById('unp'+f).value;
    tot_arr     = document.getElementById('tot'+f).value;


    field = field+"<table class='style5'><tr bgcolor='#FFFFFF'>";
    field = field+"<td width='70'><b>"+f+"</b></td>\n";
<? if($_POST['type']!="s"){ ?>  
    field = field+"<td width='130'>";
    field = field+"<input name='itn[]' id='itn"+f+"' type='text' class='input' size='5' maxlength='11' value='"+itn_arr+"'>";
    field = field+"</td>\n";
<? } ?> 
    field = field+"<td width='200'>";
    field = field+"<input name='desc[]' id='desc"+f+"' type='text'
  class='input' size='30' value='"+desc_arr+"'>";
    field = field+"</td>\n";                            
    field = field+"<td width='70'>";
    field = field+"<input name='qty[]' id='qty"+f+"'
 onchange='totcalc("+f+");' type='text' class='input' size='3' 
value='"+qty_arr+"'>";
    field = field+"</td>\n";
<? if($_POST['type']=="o"){ ?>          
    field = field+"<td width='70'>";
    field = field+"<input name='cls[]' id='cls"+f+"' type='text'
 class='input' size='3' value='"+cls_arr+"'>";
    field = field+"</td>\n";
<? } ?>         
    field = field+"<td width='150'>";
    field = field+"<input name='unp[]' id='unp"+f+"' 
    onchange='totcalc("+f+");digit("+f+")' type='text' class='input' 
    size='10' value='"+unp_arr+"'>";
    field = field+"</td>\n";
    field = field+"<td width='150'>";
    field = field+"<input name='tot[]' id='tot"+f+"' type='text' 
    class='input' size='10' value='"+tot_arr+"'>";
    field = field+"</td>\n";
    field = field+"</tr></table>\n\n";

}


var table = "<table class='style5'><tr bgcolor='#FFFFFF'>";
    table = table+"<td width='70'><b>"+count+"</b></td>\n";
<? if($_POST['type']!="s"){ ?>      
    table = table+"<td width='130'>";
    table = table+"<input name='itn[]' id='itn"+count+"' type='text'
 class='input' size='5' maxlength='11'>";
    table = table+"</td>\n";
<? } ?>     
    table = table+"<td width='200'>";
    table = table+"<input name='desc[]' id='desc"+count+"' type='text'
 class='input' size='30'>";
    table = table+"</td>\n";
    table = table+"<td width='70'>";
    table = table+"<input name='qty[]' id='qty"+count+"' 
onchange='totcalc("+count+");' type='text' class='input' size='3'   
value='0'>";
    table = table+"</td>\n";
<? if($_POST['type']=="o"){ ?>  
    table = table+"<td width='70'>";
    table = table+"<input name='cls[]' id='cls"+count+"' type='text'     
class='input' size='3'";
    table = table+"</td>\n";
<? } ?>         
    table = table+"<td width='150'>";
    table = table+"<input name='unp[]' id='unp"+count+"' 
onchange='totcalc("+count+"); digit("+count+")' type='text' 
class='input' size='10' value='0.00'>";
    table = table+"</td>\n";
    table = table+"<td width='150'>";
    table = table+"<input name='tot[]' id='tot"+count+"'  
    type='text' class='input' size='10' value='0.00'>";
    table = table+"</td>\n";
    table = table+"</tr></table>\n\n";



    document.getElementById("add").innerHTML = field + table;

    document.getElementById("count").value = (count*1);
}

Later everything will be posted to the a div id='add' container in a nested table.

When I post the form there are no variables posted.

6
  • 1
    where is your form html?
    – Raheel
    Mar 2, 2015 at 17:23
  • Dunno if I didnt get you wrong, but is this file.js or file.php with <script type="javascript>? You cannot use PHP in a .js file, so obv. it wont work.
    – Eda190
    Mar 2, 2015 at 17:25
  • HTML is on top. I just copied and pasted my JS here. It's a .php file. Mar 2, 2015 at 17:28
  • Hard for anyone to assess a form problem when no form code is shown and no ajax ( if that is being used). Suggest you create a smaller test version for yourself
    – charlietfl
    Mar 2, 2015 at 17:30
  • I'm just posting from a form. It's really a lot of code. <form action="orderseditact.php" method="post" > <tr> <td colspan='2'>Customer: </td> </tr>... <div id='add'></div> ... <tr> <td></td> <td> <input type='hidden' name='id' value='<?=$id;?>'> <input type='reset' value='reset' class='button2'> <input type='button' onclick='history.go(-1);' class='button2' value='back'> <input type='submit' value='send' name='send' class='button2'> </td> </tr> </form> Mar 2, 2015 at 17:40

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.