sent parameter new Option(this.name, this.id) to function error

sent parameter new Option(this.name, this.id) to function error

ballprogrammerballprogrammer Posts: 11Questions: 0Answers: 0
edited June 2013 in DataTables 1.8
html
[code]

abc

[/code]


data
[code]
data1 = [ { "id": "1", "name": "name1" },
{ "id": "2", "name": "name2" },
{ "id": "3", "name": "name3" }];
data2 = [ { "id": "1", "value": "value1" },
{ "id": "2", "value": "value2" },
{ "id": "3", "value": "value3" }];
data3 = [ { "id": "1", "text": "text1" },
{ "id": "2", "text": "text2" },
{ "id": "3", "text": "text3" }];
[/code]
script
[code]
$('#select1').empty();
$('#select1').append(new Option("name0", 0));
$.each(org_position, function () {
$('#select1').append(new Option(this.name, this.id));
});
[/code]
is ok select option data

problem
i want create function to
[code]
function set_select_option(select_name, start_value, data, new_option) {
select_name.empty();
select_name.append(new Option(start_value.toString(), 0));
$.each(data, function () {
select_name.append(new_option) ;
});
};
[/code]
i want use this
[code]
set_select_option('#select1', 'name0', data1, new Option(this.name, this.id));
[/code]
this error
[code]
Option(this.name, this.id)
[/code]
how to fix ?

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    I'm not sure how this relates to DataTables? It looks like a general Javascript question. This is a forum specifically for DataTables. You'd be better off asking on SO or similar.

    Allan
  • ballprogrammerballprogrammer Posts: 11Questions: 0Answers: 0
    sorry i post wrong group
  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    You just posted the same question again in the DataTables forums, which I've now deleted. As I said, the forums on this site are for DataTables questions, not general Javascript questions. You can use StackOverflow or similar for general programming questions.

    Allan
  • ballprogrammerballprogrammer Posts: 11Questions: 0Answers: 0
    thank you, i understand
This discussion has been closed.