How to display an alert and clear fields with classic asp?

2

How do I display an alert and clear the textbox fields in asp classic? I'm starting to mess with classic asp now, I'm lost, just know asp.net. Can I use something from ASP.NET?

    
asked by anonymous 29.05.2015 / 22:09

1 answer

2

You can not display an alert or clear controls with asp, use javascript for this. The most you can do is insert the javascript code on the asp page, something like this:

<% response.write("<script language=""javascript"">alert('Olá, fui criado com asp!');</script>") %>

To clear a textbox:

<% response.write("<script language=""javascript"">document.getElementById('meutextbox').value = ''</script>") %>

If you want to clear all textboxes on the page, you can create a javascript function like this:

<script type="text/javascript">
    function limparTextboxes() {
        var textboxes = document.getElementsByTagName('input');
        for (var i = 0; i < textboxes.length; i++) {
            if(textboxes[i].getAttribute("type") == "text")
                textboxes[i].value = "";
        }           
    }
</script>

And call it with asp like this:

<% Response.Write("<script language=""javascript"">limparTextboxes();</script>") %>
    
29.05.2015 / 23:09