Hi, I am trying to create the following Object(into JSON) out of a table(with text box). However I am having trouble joining the 'rsn': 'X100' with the boardingzone[] array.
For a better understand please read through the code below. Thank you in advance for any comment or reply.
This is the JSON i am trying to create:
{ "name": txtRouteName.val(),
"serial": [
{ "rsn": "X100",
"boardingzone": [
{ "name": "Foo", "time": "8:00" },
{ "name": "Bar", "time": "8:15"}
]
},
{ "rsn": "X101",
"boardingzone": [
{ "name": "Foo", "time": "9:00" },
{ "name": "Bar", "time": "9:15"}
]
}
]
};
This is the coding I have been testing on:
function getroute(){
var boardingzone = [];
var serial =[];
var a = {
'name': 'Foo', //$('#row0c2').val()
'time': '8:00' //$(#row1col2).val()
};
var b = {
'name': 'bar', //$('#row0c3').val()
'time': '8:15' //$('#row1c3').val()
};
boardingzone.push(a);
boardingzone.push(b);
var c = {
'rsn': 'x100',
'boardingzone': boardingzone[0] // this won't get pushed into the array
Hi, I am new to jQuery and I am trying to control the table's column with a slider, the only problem I am having now is to delete the number of columns that exceeds the slider values without affecting the fixed columns. Any advise or help on pointing me to the right direction will be greatly appreciated.
<table id="table1" border="1">
<thead>
<tr>
<td>Fixed columns</td>
<td>columns</td>
<td>Fixed columns</td>
</tr>
</thead>
<tbody>
<tr>
<td>Fixed columns </td>
<td>column 2</td>
<td>Fixed columns </td>
</tr>
</tbody>
</table>
I have tried using the same method to select the <td> and remove the columns as shown in the script below but nothing have worked out so far.
function controlcol(){
var a = 1; //column to start appending (index)
var f = 2; //number of fixed column
var b = $( "#dropdownlist" ).val();
var c = $( "#table1 tr:first td").length;
var d = $( "#table1 tr").length;
var e = "<td>Added column</td>";;
//remove added column
for(var g = b; g < c-f; g++){
}
//add columns... per row
for(var i = c - f; i<b; i++){
for ( var x=1; x<d; x++){
$("#table1 tr:eq(" + x + ") td:eq(" + a + ")").after(e);
}
}
//add first row
for(var z = c-f; z < b; z++){
$("#table1 tr:eq(0) td:eq(" + a + ")").after("<td>Column</td>");