Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
It's my first project. I have 2-tables like table1, table2 contains 2-columns with data's. Now I wish to set to my table2 Select ID="counts" Option value & text from table1 cell values... like one,two,three,four,five,six Is it possible? Thank for the helps

My Codes

HTML
<table id="table1"  table-layout="fixed" border="1" width="100%" height="450px"> 
<tr>
   <td><span style="max-width:20%; color:white;">one</span></td>
   <td><span style="max-width:20%; color:white;">two</span></td>
</tr>
<tr>
   <td><span style="max-width:20%; color:white;">three</span></td>
   <td><span style="max-width:20%; color:white;">four</span></td>
</tr>
<tr>
   <td><span style="max-width:20%; color:white;">five</span></td>
   <td><span style="max-width:20%; color:white;">six</span></td>
</tr>
</table>

And My table2 is having the following code

HTML
<table id="table2"  table-layout="fixed" border="1" width="100%" height="450px"> 
<tr>
   <td><span style="max-width:20%; color:white;">Ram</span></td>
   <td><span style="max-width:20%; color:white;">Govindha</span></td>
</tr>
<tr>
   <td><span style="max-width:20%; color:white;">Khandha</span></td>
   <td>
       <select id="counts">
               <option value="text4">text4</option>
               <option value="text1">text1</option>
               <option value="text2">text2</option>
               <option value="text3">text3</option>
       </select></td>
</tr>
<tr>
   <td><span style="max-width:20%; color:white;">Ganesh</span></td>
   <td><span style="max-width:20%; color:white;">Ramesh</span></td>
</tr>
</table>


What I have tried:

I try to Set table2 Select ID="counts" Option values from table1 cell values
Posted
Updated 28-Jul-20 21:39pm
Comments
Richard MacCutchan 28-Jul-20 4:29am    
What is the problem?
Paramu1973 28-Jul-20 4:35am    
Thank Richard, Iam better in my profession because of this Richard.
And I wish to have any sample coding to Set the Option, Thank Richard

you have still not explained your problem. however, maybe this is what you need to look at: HTML select tag[^].
 
Share this answer
 
Comments
Paramu1973 28-Jul-20 8:31am    
Thank Richard, From the above codes table2 having Select ID="counts" option values I wish set it from table1 data's like

one
two
three
four
three
four


Is it possible? Thanks
Richard MacCutchan 28-Jul-20 8:55am    
I think that would need some code, either Javscript or PHP. But, again I am not sure what exactly you mean, or why you need the first table.
Paramu1973 28-Jul-20 13:50pm    
Thank Richard, giving reply to my messages, It's for website. table1 contains Images with title & amount. Table2 will be the order form which has to select by the public from website. And hence the table2- Select "counts" Options text will be from table1 cell vales.
Richard MacCutchan 28-Jul-20 14:51pm    
Then you need to add the code to extract the values from table1 and build the names into table2. The simplest way would be with PHP, as I mentioned above.
Thank Richard, I found the following codes gave me the solutions for Dynamic Select Options.
HTML
<table id="myordertable">
    <tr>
        <td><span style="max-width:20%; color:green;">Code</span></td>
        <td><div id="dynamicInput"></div></td>
        <td><input type="text" id="code" name="code" placeholder="Design Code.."></td>
    </tr>
</table>

<script>
document.getElementById("dynamicInput").onload =addInput('dynamicInput');
function addInput(divName) {
var newDiv = document.createElement('div');
var selectHTML = "";
selectHTML="<select>";
for (var row = 0; row < 2; row++) {
    for (var col = 0; col < 5; c++) {
        var MyVal=document.getElementById("mytable").rows[row].cells[col].innerHTML;
        selectHTML += "<option value='" + MyVal + "'>" + MyVal + "</option>";
    }
}
selectHTML += "</select>";
newDiv.innerHTML = selectHTML;
document.getElementById(divName).appendChild(newDiv);
} 
</script>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900