Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2004
    Location
    Pennsylvania
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question need javascript/ASP help with how to make button to run 2 actions

    I am new to javascript and I want to create a button for an ASP/web application I'm working on that will 1) prompt for two variables, startdate and enddate and 2) send them and a few other variables in a querystring to a new url. I thought it might be easiest with javascript. But if there is a better way to do this I am open to any ideas. So I would appreciate any help, links or advice. My current code attempt for the button is below:

    Code:
     <button name="show_range" type="button" style="width: 99; height: 26" onClick="return Run_My_Function()">
     <a href="show_range.asp?Identifier=<%=strIdentifier%>&EmplID=<%=strEmplID%>&EmplName=<%=Server.URLEncode(strEmplName)%>&EmplEmail=<%=Server.URLEncode(strEmplEmail)%>">
     View Range </a>
     </button>
    
    <script type="text/javascript">
     function My_Function()
    {
    var startdate = prompt("Please enter start date","")
    var enddate = prompt("Please enter end date","")
    }
     </script>
    Last edited by shandralyn; 05-05-2004 at 06:00 PM.

  • #2
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Would shandralyn or a kindhearted moderator please edit that post to wrap the code in [ code] tags? I've got some serious side-scrolling action here.

  • #3
    New to the CF scene
    Join Date
    May 2004
    Location
    Pennsylvania
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sorry

    I didn't know about code tags, but now I put them in.
    Last edited by shandralyn; 05-05-2004 at 05:21 PM.

  • #4
    New to the CF scene
    Join Date
    May 2004
    Location
    Pennsylvania
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    I think I've figure it out

    I think my problem was in trying to include both the onClick run function and the hyperlink within the button tags. So I put the command to go to the new url in the function and it seems to work now

    Code:
    <button name="show_range" type="button" style="width: 99; height: 26" onClick="return My_Function()"> 
      View Range </button> 
      
     <script type="text/javascript"> 
     function My_Function() 
     { 
        var startdate = prompt("Please enter start date","") 
        var enddate = prompt("Please enter end date","") 
       window.location="show_range.asp?Identifier=<%=strIdentifier%>&EmplID=<%=strEmplID%>&EmplName=<%=Server.URLEncode(strEmplName)%>&EmplEmail=<%=Server.URLEncode(strEmplEmail)%>" 
       return 
     } 
     </script>


  •  

    Posting Permissions

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