If you can change the HTML a little try this -
var plotMe1= [[1,2], [3,4], [5,6]];
<form>
x1: <input type="text" class="x" name="x1"/>
y1: <input type="text" class="y" name="y1"/><br/>
x2: <input type="text" class="x" name="x2"/>
y2: <input type="text" class="y" name="y2"/><br/>
x3: <input type="text" class="x" name="x3"/>
y3: <input type="text" class="y" name="y3"/><br/>
</form>
I am using jQuery so the code is -
$("input").on('keyup', function(){
var x = $.map($("input.x").toArray(), function(e){
return $(e).val();
});
var y = $.map($("input.y").toArray(), function(e){
return $(e).val();
});
plotMe1 = [];
for(var i = 0; i < x.length; i++){
plotMe1[i] = [x[i], y[i]];
}
});
Here you go, this will also help you use more inputs if you like. I haven't tested on fiddle, but should work.
But if you are not at liberty to change the HTML try the following code -
$("input").on('keyup', function(){
var x = $.map($("input[name^='x']").toArray(), function(e){
return $(e).val();
});
var y = $.map($("input[name^='y']").toArray(), function(e){
return $(e).val();
});
plotMe1 = [];
for(var i = 0; i < x.length; i++){
plotMe1[i] = [x[i], y[i]];
}
});
Personally I don't like the 2nd approach cause if searches with name starting with x or y, so that might cause errors if there are more inputs starting with these but have different purpose, i would suggest the first approach, using classes for specific inputs.