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 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    updating multiple items on a web page

    I am fairly new to HTML, and am getting stuck with simple concepts that work in non web-based code. Hopefully what I am looking to do is simple, but it seems HTML lacks this functionality (for security reasons).

    When updating a web page, if you have the same information in several places, it would be easier to update one object and have it dynamically update all objects of that type (name, etc). I considered using a file to update the information, that was a no-go. I considered using javascript, but nothing I do seems to be working.

    an example:

    Lets say I have 3 different kinds of cookies on a web site, each has multiple locations. One of the cookies changes its name from banana nut to nutmeg. Is there an easy way to input that information in one place and have it updated in all pertinent locations?

    I have looked in posts up to 10 pages back and have not seen any that touch on this topic. Any help offered would be greatly appreciated.

  • #2
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,311
    Thanks
    11
    Thanked 285 Times in 284 Posts
    I had to read this a couple times, because "updating a cookie" has meaning in the web space beyond what I think you mean. If you're talking about cookies from a bakery, then the typical way you'd change their names is to have all the cookie information in a database, and any page that needed information about them would pull it from the database. Then one change in the database would affect all relevant pages.

    So this would be a server-side function, using PHP or ASP, and a database.

    Dave

  • #3
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Im trying to do this while avoiding databases, as im not really up to par on those either. I was trying to keep it compartmentalized and just as one big whole, rather than multiple components as I teach myself a little about HTML and its capabilities. About the only work-around I can think of is to declare a variable in javascript and assign that variable to show up in a DIV segment. Been busily looking through posts and such trying to determine if that is possible.

  • #4
    Regular Coder
    Join Date
    Jul 2011
    Location
    India
    Posts
    496
    Thanks
    3
    Thanked 57 Times in 56 Posts
    What you want to do is not possible with HTML only, there are following ways to do same:

    1. If your data values are not too many store them in Javascript array.
    2. If your data is huge, then you have to use database only.


  • #5
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    One thing you will need to realize early on, is the limitations strict html has. One being that html alone cannot store, pass, or manipulate data.

    Now, perhaps, if I'm understanding your issue correctly, you could use includes to "change" data in multiple locations. You would need to use a server side language to do this though, but its really a very simple process.

    If you have a common page element, say for example a header, that is the same on all pages in your site. You could separate this code from all pages and place in a separate file. Then with one line( an include) you can include this whole code block in every page that has the include statement. The advantage to this is that you can edit that separated file as much as you like, and this would be reflected in every instance where its used. Before I go further, make sure this might be something you could use.
    Teed

  • #6
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,776
    Thanks
    41
    Thanked 196 Times in 195 Posts
    @tracknut... i got so confused as to the whole cookie naming thing until I read your post as well lol

    @OP...
    I agree with what pretty much everyone is saying... i wanted to throw into the mix... and for anyone readin, this is "not how I roll" you may want to consider an access database... I do not generally recommend this (as some of my work entails going through and fixing ppl who have decided to go this route) but if you are a small business and only you will be using then go for it... EVERYTHING is wizards... you make "sql" statements using wizards, you format your tables using wizards... you can make macros (again using wizards) and then click a fun little button that converts it to VB... for the person who doesn't want to learn database stuff, it works... some things to keep in mind
    there is only 2G of database space
    only one user can access the database at a time
    Again- i do not generally recommend this solution, but i think in your case it is a viable solution

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • #7
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for all the responses folks. Your answers have helped narrow down the solution to my problem. I have been researching a little and found the limitations of HTML, noted that certain things just cannot happen. I think I have decided to use a javascript class to store set data, and to input that data into a div.

    The data is simply from research, and needs to be updated occasionally. It is a lot easier for me to update the data in one location (or add new data points) than it is to go to every single point the data is entered on the several HTML pages that it exists.

    I suppose that does bring out one more question from me though. How would this method work security-wise? I do not want someone being able to hack into the site and alter the data values that have been entered into the java class. It is not finished yet, but here is an example of how I used it.

    /*in the HTML file*/
    <script src="Variables.js"></script>

    The class itself is defined in Variables.js, and holds all the values that I need stored. In the specific location on whatever page the data happens to reside, I should just be able to include a document.write function to put that data into a DIV element (havent quite gotten that far yet).

    Is this a fairly secure method or should I try to learn databases?

  • #8
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,338
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Personally I never recommend using javascript for ANY functionality of a website. Javascript should be used to enhance a user's experience. The fact that you may rely on client side for any important piece of a page, and given that browsers cal elect to turn off js, might through a kink in this route.

    Again, this can be done with server side scripts just as easy, and will not matter what the user chooses to turn on or off in their browsers, it will just work.
    Teed


  •  

    Posting Permissions

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