Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

321
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda