0

I have this function and i want to grab the values from the prmpts and instert them in the transformation matrix. For some reason this is not working. I am thinking that the problem is because i need to use "" before and after each var but because its already within the " " 's of the transformation matrix i cant nest them. Any ideas?

This is my code.

<script>
function output() {
    var transformw = prompt("Enter your new width");
    var transformh = prompt("Enter your new height");
    var newnew = 4;
    svgCanvas.changeSelectedAttribute("transform", "matrix( transformw, 0, 0, transformh, 0, 0)");
    svgCanvas.recalculateAllSelectedDimensions();
}
</script> 

I have this function and i want to grab the values from the prmpts and instert them in the transformation matrix. For some reason this is not working. Any ideas?

dfsq
  • 191,768
  • 25
  • 236
  • 258
nicholaswmin
  • 21,686
  • 15
  • 91
  • 167

1 Answers1

1

It does not work because this is a string:

"matrix( transformw, 0, 0, transformh, 0, 0)"

You should concatenate the string with the variables, like this:

svgCanvas.changeSelectedAttribute("transform", "matrix(" + transformw + ", 0, 0, " + transformh + ", 0, 0)");
antoyo
  • 11,097
  • 7
  • 51
  • 82
  • THANK YOU! i used transformW=parseInt(transformw) below the prompt lines. Same for transformh and it still didnt work. Any ideas why? Doesnt this turn the string into an integer? Your line worked like a charm thanks. – nicholaswmin Feb 17 '13 at 21:02