fredster1777
fredster1777

Reputation: 23

Using Perl to update HTML

I am having trouble wrapping my head around getting Perl to work with HTML. I am trying to do something I think is simple, but I cant find anything like it online.

Let's say I have a blank web page that has only a button labeled new, and when I press it, I want to destroy the button and create two new buttons, one that is a submit button, and one cancel that creates the old new button.

How would I go about doing that, without reloading the page?

From my understanding, the original HTML code would look something like this.

<form action="/cgi-bin/switchButtons.cgi" method="POST">
<input type="button" value="new">
</form>

and afterward should look like this.

    <form action="/cgi-bin/switchButtons.cgi" method="POST">
    <input type="submit" value="submit">
    <input type="button" value="cancel">
    </form>

On pressing cancel, it should refer back to the first snippet.

Upvotes: 0

Views: 143

Answers (1)

Borodin
Borodin

Reputation: 126722

You can't do that.

/cgi-bin/switchButtons.cgi is a Perl program on the server. Clicking on one of the form's buttons sends a request message to the server, which runs switchButtons.cgi. The output from that program is the contents of a new web page which is sent back to the client (the browser). Of course that involves loading a new page

You could do it in JavaScript, which is part of the page and runs on the client. You can specify that a button will cause the browser to execute some JavaScript, which could alter the page 9n any way you want. But that doesn't answer your question

Upvotes: 3

Related Questions