Global variable or cookie in javascript

Ask a Question related to Macromedia Dynamic HTML, Design and Development.

  1. #1

    Default Global variable or cookie in javascript

    Ok heres the problem... I have a list of music that is searchable. I designed
    it in coldfusion and want to add a little javascript to be able to change the
    text size. Currently the following code works, but then when you search again
    after changing the text size it will revert back to the default text size. I
    believe that this can be done using a global variable but I'm not sure how I
    would do it in this situation. Also I believe that I could use a cookie but I
    would prefer not to if possible.

    This is the link to the page...
    [url]www.jasonschwab.com/music.cfm[/url]

    The javascript....
    --------------------------------------------------------------
    <script language="javascript">
    function ChangeFontSize(size) {
    id = "results";
    document.getElementById(id).style.fontSize = size + "px";
    }
    </script>
    --------------------------------------------------------------

    The html......
    --------------------------------------------------------------
    <a href="#" onclick="ChangeFontSize('20')">Change to 20px</a><br>
    <a href="#" onclick="ChangeFontSize('28')">Change to 28px</a><br>
    <a href="#" onclick="ChangeFontSize('36')">Change to 36px</a>

    <TABLE id="results">
    <TR>
    <TD>
    This is the text that I would like to change
    </TD>
    </TD>
    </TABLE>
    --------------------------------------------------------------

    Now don't get me wrong...The above code does work, but when I search again,
    this changed font size value is lost. How do I get it so that once someone
    clicks to change the font size it will stay that font size until they close the
    browser?

    What I think might need to be done is to somehow pull a variable out of the
    function and then set that as the default value...But I' really not sure...

    Thanks again,
    Jason

    jasonwsaz Guest

  2. Similar Questions and Discussions

    1. cookie variable
      Hi everyone. Im not a coldfusion programmer nor user. I didn't know where to turn for help so I came on this board. The trouble I am having is a...
    2. Javascript Cookie help
      Hi, I have a site that already has a cookie. what I need to do is append to that cookie. So it's got a variable and value right now such as...
    3. Ever tried to set cookie expiry date using JavaScript?
      Hi all. I'm trying to set a cookie expiry date but my script is JS (JavaScript). I've tried Response.Cookies("Test").Expires = Date();...
    4. Help Please: 'Warning 5001 global variable "iF_timer" already defined in global scope
      Hi there, I have just started to get this error: 'Warning 5001 global variable "iF_timer" already defined in global scope The variable name...
    5. passing javascript variable into asp variable using vbscript
      The subject pretty much sums up what I need to do. Here is what I have so far, but still can't figure out how to get it working: <script...
  3. #2

    Default Re: Global variable or cookie in javascript

    Setting a cookie will let you set the font size from the cookie from that time
    forward. You could also pass a variable from page to page with the chosen font
    size. If this is a search page, then there's likely a form on it, and you can
    use a hidden field in the form to pass the variable. This would probably work
    out best when the user will be mostly going back and forth between the form
    page and the action page.

    delaneypub Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139