SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Procrastinator Extraordinaire lucas's Avatar
    Join Date
    Oct 2000
    Location
    Springfield, Missouri, U.S.A.
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how do i implement a refresh function on a form?

    hey all,

    i want to have two options on a form, one to refresh the form, and another to submit the form.

    the way i have it set up now is through a regular html form with asp doing the calculations needed in it. if i change the value in a textbox, i want to be able to press refresh and have asp recalculate it. i'm able to do that, but now i don't have a way to actually submit the form because i already have a form method that sends it back to asp for recalculation.

    can you think of a way to submit a form to two different locations based on two different buttons?

  2. #2
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    OK, let's say you have 2 buttons, one called "Refresh" and one called "Submit".

    Here's your HTML code for each button:

    Code:
    <input type="button" name="Refresh" value="Refresh Page" onClick="changeAction('refresh');" />
    <input type="button" name="Submit" value="Submit form" onClick="changeAction('submit');" />
    Here's the javascript that will change where your form goes based on which button is clicked.

    Code:
    <script language="javascript" type="text/javascript">
     function changeAction(event){
       if(event=='refresh'){
         document.form1.action='refreshedpage.asp';
        }else{
         document.form1.action='submitpage.asp';
        }
        document.form1.submit();
      }
    </script>
    NOTE: Change 'form1' in the javascript to the name of your form, and the names of 'document.form1.action' to your real pages you wish to change.

    Hope this helps!

    --Vinnie

  3. #3
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how bout this...
    Code:
     <input type=button value=refresh onclick="javascript:window.location.reload()">
    seems to work fine.
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  4. #4
    Rehab is for quiters! spartan's Avatar
    Join Date
    Apr 2002
    Location
    Cape Town, South Africa
    Posts
    343
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DOH

    ignore previous post
    dont know how I read that question


    thought you wanted a refresh button for your page.

    *the White Russians made me do it*
    I will refrain from posting again today. will be back when these voices shut up
    Spartan
    ---------------------
    It's like our sergeant told us before one trip into the jungle. Men! Fifty of you are leaving on a mission. Twenty-five of you ain't coming back.
    -Mr.Payne

  5. #5
    SitePoint Wizard
    Join Date
    Jan 2001
    Location
    Milton Keynes, UK
    Posts
    1,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can also do this in ASP by checking to see which button was used for the Submit. If you use Submit type buttons then only a name/value pair will be submitted for the button that was clicked. You can then check to see which button was submitted.

    Code:
    <%
    
    Function ProcessForm()
    
    	'Determine which button was pressed
    	If (Not IsEmpty(Request.Form("btnRefresh"))) Then
    		ProcessRefresh
    	ElseIf (Not IsEmpty(Request.Form("btnSubmission"))) Then
    		ProcessSubmission
    	End
    
    End Function
    
    
    Function ProcessRefresh()
    
    	... Refresh code to go here
    
    End Function
    
    Function ProcessSubmission()
    
    	... Submission code to go here
    
    End Function
    
    %>

  6. #6
    Procrastinator Extraordinaire lucas's Avatar
    Join Date
    Oct 2000
    Location
    Springfield, Missouri, U.S.A.
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wink

    your awesome guys, thanks shane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •