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

147
Vistas
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 Respuestas
Responde la pregunta

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 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