#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    9
    Rep Power
    0

    Question how do i reload the page to show new info with multiple submit buttons


    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

    Comments on this post

    • Gran Roguismo agrees
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    9
    Rep Power
    0

    Thumbs up all sorted


    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]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    15
    Rep Power
    0
    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.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    9
    Rep Power
    0

    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?
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    15
    Rep Power
    0
    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)...
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Location
    egypt
    Posts
    16
    Rep Power
    0

    Question i had misunderstanding now


    So jholmes

    i had misunderstanding now
    Whats the real different between GET and POST
    and i mean all differents



    thank u for help
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    15
    Rep Power
    0
    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

IMN logo majestic logo threadwatch logo seochat tools logo