40 users online (1 members and 39 guests)  


  Results 1 to 2 of 2

Related

  1. Radio Buttons Return Nothing    Forum: HTML Forum
    Replies: 7
  2. Labels for radio buttons inside a row    Forum: HTML Forum
    Replies: 11
  3. cookies and drop down menu    Forum: PHP Forum
    Replies: 4
  4. Drop down menu with changing pic    Forum: Javascript Forum
    Replies: 4
  5. radio buttons    Forum: HTML Forum
    Replies: 2
  1. #1
    Snufelupogus's Avatar
    New User

    Status
    Offline
    Join Date
    Dec 2008
    Posts
    1

    Changing radio buttons to drop-down menu and maintain cookies

    Hi,

    I have been trying to convert my radio buttons to a drop down menu, however I have been having difficulties doing so and still have the cookies working.

    Would anyone have an idea of how I could do this?

    Thank you very much and have a wonderful day!

    CODE:

    <html>
    <HEAD>

    <SCRIPT LANGUAGE="JavaScript">
    var expDays = 30;
    var exp = new Date();
    exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

    function getCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
    }
    function GetCookie (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
    return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
    }
    return null;
    }
    function SetCookie (name, value) {
    var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
    ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    ((path == null) ? "" : ("; path=" + path)) +
    ((domain == null) ? "" : ("; domain=" + domain)) +
    ((secure == true) ? "; secure" : "");
    }
    function DeleteCookie (name) {
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    var cval = GetCookie (name);
    document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString
    ();
    }

    var favorite = GetCookie('location');

    if (favorite != null) {
    switch (favorite) {
    case 'Barrie' : url = "http://www.google.ca/";
    break;
    case 'Toronto' : url = "http://www.yahoo.ca";
    break;
    case 'London' : url = "http://www.statcounter.com";
    break;
    case 'Sarnia' : url = "http://www.chapters.ca";
    break;
    }
    window.location.href = url;
    }
    // End -->
    </script>

    <title>Select your region</title>
    <link rel="stylesheet" href="Assets/dialog.css" type="text/css">
    </HEAD>
    <BODY bgcolor="13548B">
    <center>
    <form>
    <p>Welcome to the jungle<br>
    </p>
    <table width="0">
    <tr>
    <td align="center">
    <p>Please select a region. </p>
    <hr>
    <p>
    <input type="radio" name="Barrie" onClick="SetCookie
    ('location', this.name, exp);">
    Barrie
    <input type="radio" name="Toronto" onClick="SetCookie
    ('location', this.name, exp);" onclick="setPage()">
    Toronto
    <input type="radio" name="London" onClick="SetCookie
    ('location', this.name, exp);" onclick="setPage()">
    London
    <input type="radio" name="Sarnia" onClick="SetCookie
    ('location', this.name, exp);">
    Sarnia</p>
    <hr>
    <p>
    <input type="submit" name="Submit" value="Select Me!">
    </p>
    </td>
    </tr>
    </table>
    </form>
    </center>
    </body>
    </html>

  2. #2
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: Changing radio buttons to drop-down menu and maintain cookies

    Could you post the way the cookies are currently set up?



Tags for this Thread