|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
hi all,
i am new to asp and web designing, and was wondering how to reload a page so that a different set of images appear, depending on which submit button is pressed. <center> <form> <br><p> Choose the year to view: <br><br> <input type="submit" value="1800" name=year1800> <input type="submit" value="1850" name=year1850> <input type="submit" value="1900" name=year1900> <input type="submit" value="1950" name=year1950> <input type="submit" value="2000" name=year2000></center> </form> i'm not sure how to use the various values. would i need to use an IF statement, and if so, how? any help would be much appreciated. j |
|
#2
|
|||
|
|||
|
don't worry folks. I managed to sort it out. found a site which really helped due to the relevant example:
[URL=http://www.4guysfromrolla.com/webtech/040499-1.shtml[/URL] |
|
#3
|
|||
|
|||
|
instead of making the names for all the submit buttons different, make them the same. then when the user hits submit, the value of that submit button will be sent to the asp page. in the asp page, you can then use Request.Form to get the value of what button was pressed using one name.
or, in the form, use this: <center> <form> <br><p> Choose the year to view: <br><br> <input type="submit" value="1800" name="year"> <input type="submit" value="1850" name="year"> <input type="submit" value="1900" name="year"> <input type="submit" value="1950" name="year"> <input type="submit" value="2000" name="year"> </center> </form> (examples i give are in jscript!) then in the asp page, get the value of year: year = Request.Form("year"); then use an if statement (or case...) to write fill in the variables which the page will show: if (year == "1800") { pic1 = "1800_1.jpg"; pic2 = "1800_2.jpg"; etc. } else if (year == "1850") { pic1 = "1850_1.jpg"; pic2 = "1850_2.jpg"; etc. } then show the pictures: in html: <img src="<%=pic1%>"> <img src="<%=pic2%>"> or in asp: Response.Write("<img src='" + pic1 + "'>"); Response.Write("<img src='" + pic2 + "'>"); etc. |
|
#4
|
|||
|
|||
|
thanks for the help
thanks for the help jholmes. i just figured it out though. my code looks like this:
<% Dim mapyear mapyear = CStr(Request("year")) Response.Write(mapyear) %> </pre> <%if mapyear = "1800" then %> <img alt= "works" src="images/pics/pigs.bmp"> <%elseif mapyear = "1850" then %> <img alt= "works" src="images/pics/horses.bmp"> <%elseif mapyear = "1900" then %> <img alt= "works" src="images/pics/cows.bmp"> <%end if%> <pre> </pre> <form METHOD="Get"> <br><p> Choose the year to view: <br><br> <input type="submit" value="1800" name=year> <input type="submit" value="1850" name=year> <input type="submit" value="1900" name=year> <input type="submit" value="1950" name=year> <input type="submit" value="2000" name=year> </form> it works, but i don't know if its the best method. I'll take your points into careful consideration cheers. oh, just one more question. i know there are several advantages of using post, but are there any benefits of using get as opposed to post? |
|
#5
|
|||
|
|||
|
from my experience, GET works good for short variables, which you can easily use to assemble urls. so if there are a few things you want to set on the page when it loads, and you (not the user) are controlling the querystring, GET is excellent. however, as i found out the hard way while writing the application i'm currently working on, GET becomes extra-sketchy with multi-line inputs and apostrophes/quotes. so using POST is better for maintaining data integrity, but it can be more work to put information into a form to be submitted (whereas you can just tack a querystring onto any url without using the official form elements)...
|
|
#6
|
|||
|
|||
|
So jholmes
i had misunderstanding now Whats the real different between GET and POST and i mean all differents thank u for help |
|
#7
|
|||
|
|||
|
well, the main difference between get and post is how data is sent to the next page. subsequently, retrieval of that data can require different scripting.
i can't possibly explain it as you should probably learn it, so here's a page which details the differences: http://www.cs.tut.fi/~jkorpela/forms/methods.html |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > how do i reload the page to show new info with multiple submit buttons |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|