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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    In my case can I use javascript without having to install a web server?

    Hi,
    this is my first post.
    I'm asked to develop a very simple form where once you put some data, after clicking a button, the page performs new results into a new field.
    I'm going to use javascript, ok? So I don't have to install a web server, do I?
    Moreover, if I have to pass these results towards another page where I have to develop a report to be printed, can I pass these items by using GET or POST always without having to install a web server?
    As you've probably understood, I'd like not to have to use a web server for such a simple task.
    Thanks in advance!

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Javascript is a client-side langauge. You do not have to use a web server.

    Thre are various methods of passing data from one page to another. Most usually by using a query string or a cookie.

    The HTTP GET request method is designed to retrieve information from the server. The POST request method is designed to request that a web server accept the data enclosed in the request message's body for storage.

    Quizmaster: The Washington Monument commemorates which man?
    Contestant: Abraham Lincoln

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,550
    Thanks
    78
    Thanked 4,382 Times in 4,347 Posts
    Just to make sure you understood what Philip wrote: You *can* use <form method="get"> and use it to pass information to another HTML page. There is a limit to how much data can be send that way, though, so if you have a form with dozens of fields it may not be able to send all the data. In which case you can fall back to cookies and/or local storage.

    We should point out, though, that if you intend to use this HTML page on more than one computer you will need to install it on some web server. And, even on a single computer, web pages work better (have more capabilities without causing problems) if served from a web server instead of just being served as files.

    If you describe more about what your code is supposed to do, we can perhaps help you further.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    New to the CF scene
    Join Date
    May 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    First of all thanks for your advices.
    My job is very simple.
    I have to write a web page where you insert some information about a bill.
    The form must have a button to perform a value (by using the ones entered) and then another button for passing four/five values to another page that will be the layout of the bill to be printed.
    By the way, for reading the values passed by the first form, can I use something like this:

    Int amount=request.getParameter("amount");

    where amount is one of the values passed by the GET of the previous form
    ...

    Thanks again!

  • #5
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,017
    Thanks
    203
    Thanked 2,538 Times in 2,516 Posts
    Quote Originally Posted by glauco1969 View Post
    By the way, for reading the values passed by the first form, can I use something like this:

    Int amount=request.getParameter("amount");

    where amount is one of the values passed by the GET of the previous form
    I have the idea that you are not very sure what you are doing. The best way to pass variables to another page is by using a cookie or local storage. Google for examples.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,550
    Thanks
    78
    Thanked 4,382 Times in 4,347 Posts
    This line of code
    Code:
    Int amount=request.getParameter("amount");
    is *NOT* JavaScript code.

    It *IS* Java code. (Except it's bad Java code: Int should be int. Java is case sensitive.)

    About the only similarity between Java and JavaScript is the first 4 characters of their names.

    So if your question is really about Java, then:
    (1) You are posting in the wrong forum. This forum is only for JavaScript coding.
    (2) Yes, you *WILL* have to set up a server. Specifically a JSP server. Java code such as you showed there cannot be run without a server.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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