Vous êtes sur la page 1sur 4

Using post method <!DOCTYPE html> <html> <body> <form action="demo_simpleform.

asp" method="post"> Your name: <input type="text" name="fname" size="20" /> <input type="submit" value="Submit" /> </form> <% dim fname fname=Request.Form("fname") If fname<>"" Then Response.Write("Hello " & fname & "!<br />") Response.Write("How are you today?") End If %> </body> </html> For Radio button information retrieving <!DOCTYPE html> <html> <% dim cars cars=Request.Form("cars") %> <body> <form action="demo_radiob.asp" method="post"> <p>Please select your favorite car:</p> <input type="radio" name="cars" <%if cars="Volvo" then Response.Write("checked")%> value="Volvo">Volvo</input> <br /> <input type="radio" name="cars" <%if cars="Saab" then Response.Write("checked")%> value="Saab">Saab</input> <br /> <input type="radio" name="cars" <%if cars="BMW" then Response.Write("checked")%> value="BMW">BMW</input>

<br /><br /> <input type="submit" value="Submit" /> </form> <% if cars<>"" then Response.Write("<p>Your favorite car is: " & cars & "</p>") end if %> </body> </html>

Cookies <% dim numvisits response.cookies("NumVisits").Expires=date+365 numvisits=request.cookies("NumVisits") if numvisits="" then response.cookies("NumVisits")=1 response.write("Welcome! This is the first time you are visiting this Web page.") else response.cookies("NumVisits")=numvisits+1 response.write("You have visited this ") response.write("Web page " & numvisits) if numvisits=1 then response.write " time before!" else response.write " times before!" end if end if %> <!DOCTYPE html> <html> <body> </body> </html>

Formatting the asp file with html


<!DOCTYPE html> <html> <body> <% response.write("<h2>You can use HTML tags to format the text!</h2>") %> <% response.write("<p style='color:#0000ff'>This text is styled with the style attribute! </p>") %> </body> </html>

Redirection of server and client


<% if Request.Form("select")<>"" then Response.Redirect(Request.Form("select")) end if %> <!DOCTYPE html> <html> <body> <form action="demo_redirect.asp" method="post"> <input type="radio" name="select" value="demo_server.asp"> Server Example<br /> <input type="radio" name="select" value="demo_text.asp"> Text Example<br /><br /> <input type="submit" value="Go!"> </form> </body> </html>

For check boxes <!DOCTYPE html> <html> <body> <% fruits=Request.Form("fruits") %> <form action="demo_checkboxes.asp" method="post"> <p>Which of these fruits do you prefer:</p> <input type="checkbox" name="fruits" value="Apples" <%if instr(fruits,"Apple") then Response.Write("checked")%>> Apple <br /> <input type="checkbox" name="fruits" value="Oranges" <%if instr(fruits,"Oranges") then Response.Write("checked")%>> Orange <br /> <input type="checkbox" name="fruits" value="Bananas" <%if instr(fruits,"Banana") then Response.Write("checked")%>> Banana <br /> <input type="submit" value="Submit"> </form> <% if fruits<>"" then%> <p>You like: <%Response.Write(fruits)%></p> <%end if %> </body> </html>

Vous aimerez peut-être aussi