Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

322
Vistas
Uncaught SyntaxError: Unexpected identifier in html in javascript

I was trying to determine the size of this rectangle by the user:

<svg width=parseFloat(Rectangle1.width) height=parseFloat(Rectangle1.height)>
  <rect width=parseInt(input1int) height=parseInt(input2int) style="fill:rgb(0,0,255);stroke-width:3;stroke:rgb(0,0,0)" />
</svg>

with this code:

class Rectangle{
  constructor(height, width){
    this.height = height;
    this.width = width;
    };
  function createRectangle(this.height,this.width){
    var input1 = document.getElementbyId("1stinput").value;
    var input2 = document.getElementbyId("#2ndinput").value;
    var input1int = parseFloat(input1);
    var input2int = parseFloat(input2);
    var Rectangle1 = new Rectangle(this.height=input1int, this.width=input2int);};
};

but I got a whole of five errors to me:

Uncaught SyntaxError: Unexpected identifier
index.html:25 Error: <svg> attribute width: Expected length, "parseFloat(Recta…".
index.html:25 Error: <svg> attribute height: Expected length, "parseFloat(Recta…".
index.html:26 Error: <rect> attribute width: Expected length, "parseInt(input1i…".
index.html:26 Error: <rect> attribute height: Expected length, "parseInt(input2i…".

I don't know what they mean,so I'm once again asking for your financial coding support.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

That is not valid html. If you want to set width of an element dynamically. You must set it in JavaScript. Like

document.querySelector("svg").setAttribute('width', parseFloat(Rectangle1.width))
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda