Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using client-side and navigating with parameters

Posted on 2004-08-12
6
Medium Priority
?
210 Views
Last Modified: 2010-04-07
Hi folks,
  I am still having a problem with my coding. Here's the problem. I have a page, page1, which is written in vbscript and accepts, validates and compares two dates that the user selects. I wnat to redirect them to the right page and pass the date values.
  The problem that I am having is the only command I can get to work is the window.open
command and that leads to another can of worms.
  On page 1, they select two dates and click on a button to choose whither they want a report or if they want a listing, ie "Report" or "Listing"
  on the onclick event of each button, i have a routine which validates the two dates, and compares to ensure the ending date is greater than the beginning date. This routines are written in vbscript and work well etc. If the dates are valid, I want to pass the dates to the next page. The problem is window.location.href and the window navigate command simply won't work. It just sits in the same spot.
    For the window.location.href = "page2.asp?bd=" & vbeg & "&ed=" & vend
I don't recieve any error message; the window progression bar appears to be doing something, but it just stays at the same window...
   I have also tried this:
     vstring= "page2.asp?bd=" & vbeg & "&ed=" & vend
     window.location.href = vstring

what am I doing wrong? All I want to do is pass the valid dates to the next page.
any help would be appreciated...


0
Comment
Question by:bearpaws
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 3

Accepted Solution

by:
swarnajyothirmayi123 earned 1000 total points
ID: 11781747
Just say the action page as page2.asp and make the method as get so that the values will be passed as query string. why are you using window.location.href etc..


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="vbscript">
Function Validate()
      if (1>0) then ' write your function here
      Validate=true
      End if

End Function
</script>
<body>
<form name="test1" id="test1" method="get" action="page2.asp" onsubmit="validate">
      Start Date:<input type="text" name="sdate"/>
      End Date:<input type="text" name="edate"/>
      <input type="radio" name="type" value="listing"/>Listing
      <input type="radio" name="type" value="report"/> Report
      <input type="submit" name="submit" onClick="validate"/>
</form>
</body>
</html>

On page2.asp, you can get the values using Request.querystring("sdate") and   Request.querystring("edate")
0
 

Author Comment

by:bearpaws
ID: 11783147
 thank you for responding. Perhaps I need to expound upon my coding. Page one contains several buttons of when click, will validate the dates. Depending on what button they clicked, will take them to a different page. It isn't always to page 2.They may go to page 3 or page 4 etc. Each button takes them to a different page which is by design and correct by purpose.
  I do not like using the window.open command as it creates a pop-up window. I just want to redirect them to another page passing the values. I know how to do it quite well with server-side coding, but this has to be clinet-side coding and hence, the problem with getting to the correct next page based on what button they click on....
 

0
 
LVL 25

Assisted Solution

by:James Rodgers
James Rodgers earned 1000 total points
ID: 11783487
in the buttons that submit teh page


<input type="submit" onClick="this.form.action='page2.asp'" value="Go to Page2">
<input type="submit" onClick="this.form.action='page3.asp'" value="Go to Page3">
<input type="submit" onClick="this.form.action='page4.asp'" value="Go to Page4">
<input type="submit" onClick="this.form.action='page5.asp'" value="Go to Page5">
<input type="submit" onClick="this.form.action='page6.asp'" value="Go to Page6">
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 

Author Comment

by:bearpaws
ID: 11783543
what about validating the dates and passing them to the next page??
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 11783602

<form name="test1" id="test1" method="get" action="page2.asp" onsubmit="validate">
     Start Date:<input type="text" name="sdate"/>
     End Date:<input type="text" name="edate"/>
<input type="submit" onClick="this.form.action='page2.asp'" value="Go to Page2"/>
<input type="submit" onClick="this.form.action='page3.asp'" value="Go to Page3"/>
<input type="submit" onClick="this.form.action='page4.asp'" value="Go to Page4"/>
<input type="submit" onClick="this.form.action='page5.asp'" value="Go to Page5"/>
<input type="submit" onClick="this.form.action='page6.asp'" value="Go to Page6"/>

</form>

the validation will still occur, the onClick does not override the onSubmit in the form, but your form will submit with invalidate dates unless you have it as

onSubmit="return validate"  and your function returns true or false depending on the validation,
0
 

Author Comment

by:bearpaws
ID: 11803781
Thank you both for responding. I came up with a solution which only took rewriting in javascript and one function to cover all redirections and I think it is pretty slick. What I did was create one rtn, passing a paramter to the function, do a bunch of validation and then depending on what parameter I passed, determined what page to redirect to.
   But both of you helped to point the way and gave me food for thought. Therfore, I am splitting the points which I believe is fair. If not, let me know.
 I thought I would share how I acheived my goal...
This statement was for setting up for button for email and a report
Both use same rtn, but pass a parameter indentfying where I want to go..

<tr><td>
<input type="image" onclick="CreateRtn('E');return false;" src="../images/Email.jpg" WIDTH="106" HEIGHT="35"></td></tr>
<tr><td>
<input type="image" onclick="CreateRtn('R');return false;" src="../images/Rpt.jpg" WIDTH="106" HEIGHT="35"></td></tr>



function CreateRtn(xtype)

{
       /* validating checks blah blah...*/
      /* redirect em*/
   
          if (xtype == 'L')

              {
                window.location.href = 'SendLabels.asp?bd='+ vdate

              }

          if (xtype == 'R')

              {
                window.location.href = 'SendRpt.asp?bd='+ vdate

              }
    }

   It works really well and solved a bunch of headaches..
thanks again :-)
0

Featured Post

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question