I have a problem with a form script.
The form script should do the following:
When a user selects a value from a drop down list and hits the "next" button it should take him to a specific site. Also he has the option to check a checkbox "Remeber this choice" so that when he returns to the site it remembers what he has choosen from the drop down list and automatically takes him to a specific site.
Here is my code:
Expand|Select|Wrap|Line Numbers
- <script language="JavaScript" type="text/javascript">
- <!--
- function newCookie(name,value,days) {
- var days = 100; // the number at the left reflects the number of days for the cookie to last
- // modify it according to your needs
- if (days) {
- var date = new Date();
- date.setTime(date.getTime()+(days*24*60*60*1000));
- var expires = "; expires="+date.toGMTString(); }
- else var expires = "";
- document.cookie = name+"="+value+expires+"; path=/"; }
- function readCookie(name) {
- var nameSG = name + "=";
- var nuller = '';
- if (document.cookie.indexOf(nameSG) == -1)
- return nuller;
- var ca = document.cookie.split(';');
- for(var i=0; i<ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') c = c.substring(1,c.length);
- if (c.indexOf(nameSG) == 0) return c.substring(nameSG.length,c.length); }
- return null; }
- function eraseCookie(name) {
- newCookie(name,"",1); }
- function toMem(a) {
- newCookie('theName', document.form.name.value); // add a new cookie as shown at left for every
- //newCookie('theEmail', document.form.email.value); // field you wish to have the script remember
- }
- function delMem(a) {
- eraseCookie('theName'); // make sure to add the eraseCookie function for every field
- //eraseCookie('theEmail');
- document.form.name.value = ''; // add a line for every field
- }
- //-->
- </script>
- <script type="text/javascript">
- <!--
- function goto_URL(object) {
- window.location.href = object.options[object.selectedIndex].value; }
- //-->
- </script>
<select name="name" class="" id="name">
<option selected="selected" value="">Select one</option>
<option value="de/index.php">Germany - German</option>
<option value="uk/index.php">Other - English</option>
<option value="se/index.php">Sweden - Swedish</option>
<option value="index.php">Denmark - Dalish</option>
</select>
<input type="submit" value="Next!" class="button" />
<input type="checkbox" id="checker" name="checker" /> <b>Remember this choice</b>
</form>[/HTML]
Expand|Select|Wrap|Line Numbers
- <script type="text/javascript" language="javascript">
- <!--
- document.form.name.value = readCookie("theName"); // Change the names of the fields at right to match the ones in your form.
- //document.form.email.value = readCookie("theEmail");
- //-->
- </script>
When hitting the "next" button it just takes the user to the action url and not the url specified in the option value of the select list.
Can anyone help me getting this script to work correctly...???
Thanks very much in advance!