Results 1 to 2 of 2

Thread: Dynamicly Generated Controls - Data

  1. #1
    Join Date
    Jan 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Dynamicly Generated Controls - Data

    What are some of the best ways to get data from one asp page to another asp page. Where the controls are dynamically created?

    Code:
    <script language="javascript"> 
    var gRowId = 2; 
    
    function addRow() 
    { 
    var tbody = document.getElementById('table1').getElementsByTagName('tbody')[0]; 
    var gRowId1 = gRowId;
    var row = document.createElement('TR'); 
    var cell1 = document.createElement('TD'); 
    var cell2 = document.createElement('TD'); 
    var cell3 = document.createElement('TD');
    var cell4 = document.createElement('TD');
    
    var br = document.createElement("br");
    var inp1 = document.createElement('SELECT');
    var inp2 = document.createElement('SELECT'); 
    var inp3 = document.createElement('INPUT'); 
    var inp4 = document.createElement('SELECT');
    
    
    inp1.setAttribute('name','searchby'+gRowId1); 
    inp1.id='seachby'+gRowId1;
    
    inp2.setAttribute('name','opercmb'+gRowId1); 
    inp2.id='opercmb'+gRowId1;
    
    //window.caller = document.getElementById("usertxt" + gRowId1)
    
    inp3.setAttribute('type','text'); 
    inp3.setAttribute('name','srow'+gRowId1); 
    inp3.id='srow'+gRowId1;
    
    inp4.setAttribute('select');
    
    //cell4.setAttribute('align','center');
    inp4.setAttribute('name','andor');
    inp4.onchange= function(){addRow();};
    
    
    //Cell 1
    
    opt = document.createElement('Option');
    opt.innerHTML = '';
    opt.value = '0';
    inp1.appendChild(opt);
    
    opt$start = document.createElement('Option');
    opt$start.innerHTML = 'Contract Number';
    opt$start.value = '1';
    inp1.appendChild(opt$start);
    
    opt$start = document.createElement('Option');
    opt$start.innerHTML = 'Contract Name';
    opt$start.value = '2';
    inp1.appendChild(opt$start);
    
    opt$start = document.createElement('Option');
    opt$start.innerHTML = 'Group Number';
    opt$start.value = '3';
    inp1.appendChild(opt$start);
    
    
    //Cell 2
    
    opt = document.createElement('Option');
    opt.innerHTML = '';
    opt.value = '0';
    inp2.appendChild(opt);
    
    opt$start = document.createElement('Option');
    opt$start.innerHTML = 'Equals ( = )';
    opt$start.value = '1';
    inp2.appendChild(opt$start);
    
    opt$start = document.createElement('Option');
    opt$start.innerHTML = 'Not Equal To ( <> )';
    opt$start.value = '2';
    inp2.appendChild(opt$start);
    
    opt$start = document.createElement('Option');
    opt$start.innerHTML = 'Is Greater Than ( > )';
    opt$start.value = '3';
    inp2.appendChild(opt$start);
    
    //Cell 4
    
    inp4.setAttribute('name','itemID');
    
    opt = document.createElement('Option');
    opt.innerHTML = '';
    opt.value = '';
    inp4.appendChild(opt);
    
    
    opt$start = document.createElement('Option');
    opt$start.innerHTML = 'AND';
    opt$start.value = 'AND';
    inp4.appendChild(opt$start);
    
    opt$start = document.createElement('Option');
    opt$start.innerHTML = 'OR';
    opt$start.value = 'OR';
    inp4.appendChild(opt$start);
    
    
    //cell1.innerHTML = gRowId; 
    cell1.appendChild(inp1); 
    cell2.appendChild(inp2);
    cell3.appendChild(inp3);
    cell4.appendChild(inp4);
    
    row.appendChild(cell1); 
    row.appendChild(cell2); 
    row.appendChild(cell3);
    row.appendChild(cell4);
    
    tbody.appendChild(row); 
    gRowId++; 
    } 
    
    </script>
    
    
    <form name="myform" method="post"> 
    <table id="table1" border=1> 
    <tbody> 
    <tr> 
    <th>Search Field</th><th></th><th></th>
    </tr> 
    <tr> 
    <td>    <select name="searchby" id=searchby>
          <option value="0"></option>
          <option value="1">Contract Number</option>
          <option value="2">Contract Name</option>
          <option value="3">Group Number</option>
        </select></td> 
    <td>
        <select name="opercmb" id=opercmb>
          <option value="0"></option>
          <option value="1">Equals ( = )</option>
          <option value="2">Not Equal To ( <> )</option>
          <option value="3">Is Greater Than ( > )</option>
        </select>
    </td>
    <td><input name="srow" type=text value=""></td>
    <td><SELECT id=select1 name=select1 onchange="addRow();">
    <OPTION Value=0></OPTION>
    <OPTION Value=1>AND</OPTION>
    <OPTION Value=2>OR</OPTION>
    </SELECT></td>
    </tr> 
    </tbody> 
    </table> 
    <input type="submit" name="submit" value="Submit"> 
    </form>

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I cannot see the page but, if it is all inside a form, as it should be if you are passing data - use the default HTML method for the form (get not post), require submission and have all essential fields use names, unique names in most cases. You can then use the asp Request.QueryString on the page listed in the form's HTML action attribute to get the values passed in the address by their names as listed in the form.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •