Client-Side Scripts

Client-side scripts generally consist of a few lines of Java script to perform the more simple functions which can be done using a HTML form. A very common use for this is to use a combo box and/or button to jump to different pages. Below is a simple introduction to the Java syntax, using the example of using a combo box and button to jump to other pages, although I recommend that if you want to do anything very complicated using Javascript you get a good book on the subject or look at the many examples which are in other people's pages across the Web.

The finished product of this example should look similar to that below:

  1. The first control we need to create is the drop-down box. Select Combo Box from the list of controls and name it "go". It is always advisable to use lowercase letters since then you do not have to remember which letters were uppercase when you come to use the name in the script. After naming the control, we need to add items to it. The visible text needs to be something helpful to the user. In this example, I have used the title of the pages to jump to, i.e. "Home Page", "About Forms", "Creating Forms", "Server-Side Scripts" and "Compatibility Issues". For the value of each item I have then put the relative address of the appropriate page, i.e. "../welcome.html", "about.html", "creating.html", "server.html" and "compatibility.html". Click on Add Control to insert the combo box into the form.
  2. After setting up the combo box, we need a button for people to click on after they have selected a page to go to. Click on the Button control, and name it "go". The text on the button can also be "Go". The script for loading a different page involves setting the value of the window.location property. Since when an item in a combo box is selected, the value of that item is assigned to the value of the combo box itself, we can use the code "window.location=links.value". This is in JavaScript, so select JavaScript from the language list. Again, Click on Add Control to insert the button.
  3. Since the form does not use a server-side script, we do not need to set either the Get/Post options or the Form Action property. Click on Finish to insert the form into the page.
Obviously, you can do much more than this using client-side scripts, but this does serve as an example for both how to use HTML forms and JavaScript.