[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Data between pages

Posted on 2000-04-27
11
Medium Priority
?
182 Views
Last Modified: 2010-04-09
I want to get string data from in an input field in an html page to another html page (actually a jsp)

On 'Submit' I do some preliminary validation on the string in JavaScript.  
Next, assuming the data has been determined to be valid, I want to
go to the next page (a jsp) and access that string, where it will be used in calls to Java methods.

How can I do this?

Cannot use VB/ASP.  Need this to work with both Netscape and IE
0
Comment
Question by:jdaues
[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
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 1

Expert Comment

by:Smacked
ID: 2757750
THIS code is taken from the faulding consumer site. it's copyright fluid 1999 so dont' use it in anything commercial. this code doesn't relate to your problem but it does show how to take send data through the querystring.
I'm not going to explain it so GL.

what it does at the moment is take
?location=something.htm cuts it up a bit and works out the location for a frame (if given) is something.htm

// DECLARE VARIABLES
    var strHeader;                                          // THIS IS THE STRING OF THE DOCUMENT URL
    var strStartChar;                                    // THIS IS THE START STRING FROM WHICH WE BEGIN TO LOOK FOR THE newMainFrame LOCATION STRING
      var strMainFrameLocation;                        // THIS IS THE VARIABLE WHICH HAS BEEN PROCESSED FROM THE HTTP HEADER
      var strNewMainFrame = "products/products.htm";      // THIS IS THE DEFAULT PRODUCTS PAGE LOCATION
      var strHttpHeaderString;                        // THIS IS THE HTTP HEADER STRING ie http://www.rarara.stuff 
                                                                  // IT's PROPERTY IS DETERMINED BY WHICH BROWSER IS THERE
      var strTemp;
      
      // Assign the URL of this page to a string so we can manipulate it
      if (browserName == "Netscape")
      {
            strHttpHeaderString = document.URL;
      }
      else
      {      // Internet Explorer was not allowing any string manipulation to occur to
            // strHttpHeaderString. Hours of experimentation found that adding a null
            // to the start of the string makes it process properly
            strTemp = document.location;
            strHttpHeaderString = "" + strTemp;
      }

      // find the where 'location=' starts in this document's URL
    if (version == 3.5)
      {      
            // Internet Explorer
            strStartChar = strHttpHeaderString.indexOf("?");
      }
      else
      {
            strStartChar = strHttpHeaderString.indexOf("?");
      }

      // If the text 'location=' is not in this document's URL, then the above function will return -1

      if (strStartChar != -1)
      {      
            // SO IF THERE IS INFORMATION IN THE HTTP QUERY STRING, WE GRAB IT...
            strMainFrameLocation = strHttpHeaderString.substring(strStartChar+10, strHttpHeaderString.length);
            // AND PLUG IT INTO THE MAIN PART OF THE FRAMESET.
            strNewMainFrame = "products/product_" + strMainFrameLocation;

        }
      else
      {
            strNewMainFrame = "products/products.htm";
      }

0
 

Author Comment

by:jdaues
ID: 2759562
the answer is to user request.getParameter()
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2763818
Use the GET method in the form. and acces it by using javascript, like:

MyArray = location.search.split("=" && "?")

Now MyArray[0] will contain the nameof the first field, and MyArray[1] the value...2 will contain the next fieldname etc etc etc

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:chuckie79
ID: 2764027
on the first page do something like the following

<FORM METHOD=POST ACTION="secondpage.html" ONSUBMIT="return CheckForm()" NAME="form1">
<INPUT TYPE=TEXT NAME="name">
..
..
..
<INPUT TYPE=SUBMIT>
</FORM>

then in script section include a function CheckForm(), which funnily enough checks the form. On an error it returns false. If form is ok then return true, for example

<SCRIPT LANGUAGE="JavaScript">
<!--
      function CheckForm
      {
            if (document.form1.name.value == "")
            {
                  // Maybe pop up a dialog box telling user error
                  return false;
            }
            else
            {
                  return true;
            }
      }
-->
</SCRIPT>

if form is ok the function returns true. Information is submitted to secondpage.  This needs to read in the data, and display or process it.  I am unsure how to do this in JSP but I guess there would be an object for the data.  Maybe something like Request (as it is in ASP).

I have found that the javascript CheckForm is usually best put in the HEAD section of a page.

Good luck

chuckie79
0
 
LVL 1

Expert Comment

by:HOOKUPS
ID: 2765587
Actually you can use asp in both netscape and internet explorer since all the code is executed on the server and only outputs html to the clients computer. With asp its quite easy

myVar = Request.form("thenameoftheinputbox")

That way you can fetch variables from your form to your script :-)

hopes it helps
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2765593
QUOTE

Cannot use VB/ASP

/QUOTE

READ FIRST, THEN ANSWER
0
 
LVL 1

Expert Comment

by:HOOKUPS
ID: 2765602
Well cj if you read the line it sounds like he ment that he couldnt use it because he thought that asp couldnt be used in netscape that why i wrote what i wrote
0
 
LVL 22

Expert Comment

by:CJ_S
ID: 2765642
true....depends on how you read what he wrote.
0
 

Author Comment

by:jdaues
ID: 2774374
cannot use VB/ASP
period.
0
 
LVL 22

Accepted Solution

by:
CJ_S earned 300 total points
ID: 2776361
jdaues, I provided you a way to retrieve the informion you've sent. Can you use that, or do I have to make a better function for you?

function GetQS(str)
{
    Tmp = location.search.split("=");
    for(i=0;i<Tmp.length;i++)
       if(Tmp[i]==str)
          return Tmp[i++];
    return ""
}

you pass this function the name of one of the fields you had in the form, and it will return a string with the value of it.
NOTE: you have to use the GET method in the form.

CJ
0
 

Author Comment

by:jdaues
ID: 2838110
sorry for the delay

CJ_S, as stated in my previous comment, the answer to my question is to use request.getParameter()
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

650 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