Sajid Anwar Sajid Anwar - 1 year ago 67
Javascript Question

How to insert two value in one time to array using JavaScript

I want to insert two values in one array in each loop. I have tried

feature_arr = [];
$form.find( '.variations .value' ).each( function() {
var $radios = $( this ).find( 'input[type=radio]' );
var $checked_radio = $radios.filter(':checked');
var attribute_name = $radios.attr( 'name' );
feature_arr[] = attribute_name1;
feature_arr[] = $checked_radio.val();

I want array this form
["1", "Brighton_Black", "2", "Frame_Base", "3", "Matching_upholstery", "6", "Headrest", "7", "Covered"]

But give me error this code

Answer Source

try this

var feature_arr = new Array(); // define the array or you can use feature_arr = []

and inside your condition

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download