labas GamePage visogero labas GamePage visogero - 1 year ago 46
jQuery Question

When form submit replace it with inputs value. JavaScript

I have this small form here:

<form action="prekiu-uzsakymas" method="get">
<input type="text" name="ticket" value="8888">
<input type="submit" value="Panaudoti kuponÄ…">

What I want to do is, when I click submit, the form should be hidden and only the input should appear:

<input type="text" name="ticket" value="8888">

How can I achieve this with javascript ?

Answer Source

Looks like you just want to remove the button. First, give the form and button an ID, then attach to the submit event, where you can do whatever you want to do before submission happens:

jQuery("#my-form-id").submit(function() {
    jQuery("#my-button-id").remove(); // or .css("display", "none")