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

151
Visualizações
Looking to take Quantity from a text input and use OnClick="location.href" to push information to new page

Currently I am using this to submit a quantity of 1 product to my cart page with a simple Onclick add to cart button.

<td class="data_cell dataFontColor">
                <label onClick="location.href='cart/?PartNo=#NPart#&Qty=1'">Add to 
Cart</label></td>
            <td class="data_cell dataFontColor">
                 <cfif IsDefined ("getPrice2.Price") AND getPrice2.Price eq "">

I am trying to implement a text box to submit any quantity the user wants, but on submit the page moves but nothing is added to cart. I know it's something wrong with the Qty= in the OnClick, but can't seem to figure it out. Any help would be appreciated!

<td class="data_cell dataFontColor">
            <td><input type="text" name="Qty" size="4" value= "Qty" maxlength="9"/></td>
            <td class="data_cell dataFontColor">
            <label onClick="location.href='shop/?PartNo=#NPart#&Qty=#Trim (Qty)#'">Add to 
Cart</label></td>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The reason this is not working is because you can't do what you're attempting using ColdFusion which processes the page server-side. User typed inputs are processed client-side.

First, I would add an id attribute to your input tag.

<input type="text" id="Qty" name="Qty" size="4" value= "Qty" maxlength="9"/>

Once your input has an ID, now you can now extract the value client-side using JavaScript.

<label onClick="location.href='shop/?PartNo=#NPart#&Qty="+document.getElementById("Qty").value.trim()>Add to Cart</label>
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