Meaningless Drivel is fun!*
The moose likes HTML, CSS and JavaScript and the fly likes disable button in html 5.0 with javascript based on one-four variables example Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "disable button in html 5.0 with javascript based on one-four variables example" Watch "disable button in html 5.0 with javascript based on one-four variables example" New topic
Author

disable button in html 5.0 with javascript based on one-four variables example

Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 412


I have this javascript above.

I need to be able to compare the

recordid
tableid
viewid
vrid

to what is being passed in and gray out an edit button if the values are not equal.

I have looked and looked for examples and do not know what to do about this. Any help would be appreciated.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

"This"? With a capital?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 412
var check = [
'recordid',
'tableid',
'viewid',
'vrid''];
localStorage.check = JSON.stringify(check);

// later that evening…
var html5docs = JSON.parse(localStorage.check);
alert('There be ' + html5docs.length + 'check in the house');


I am trying to figure out if I can use this code or something like it to stringify the variables passed in as html 5.0 storage objects and somehow to compare them to what has been passed to the page to turn off a button if the variables do not match what has been passed to the page.
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 412





I am trying to figure out if I can use this code or something like it to stringify the variables passed in as html 5.0 storage objects and somehow to compare them to what has been passed to the page to turn off a button if the variables do not match what has been passed to the page.
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 412


I am trying to figure out how to store these values that get passed to the page from within a frames setup and then check to see if they have been passed in for later retrieval.
Michele Smith
Ranch Hand

Joined: Oct 27, 2010
Posts: 412
I am trying to use the HTML 5.0 storage feature to store up to four variables. Could you have a look and point me in the right direction?




How could I compare the recordid, tableid, viewid, and vrid to what is passed to the page to be able to gray out an edit button? Simple question, but lots of ways to fix.

Any help would be appreciated.
Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 295
    
    5

This code:

Is creating an array with 4 strings in it, and then storing that in local storage, I'm not sure why you would do that? It's also not clear to me how the various snippets of code you've posted on this thread are supposed to connect together, can you post one complete example?

Here's a quick tutorial on localStorage: if you have four variables like this:

Then you can wrap them up into an object and stick them in localStorage like this:

You would then later extract the object with code like this:

Here is some code you can play with.

Of course if it's just four variables, you could just stick them into localStorage directly and save yourself the hassle of the wrapping and JSON manipulation.


Read my books: Hello! HTML5 & CSS3 | HTML5 in Action | Read my blog
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You are the first person that I have ever seen referring to html5 as 5.0.
Rob Crowther
author
Ranch Hand

Joined: Nov 06, 2012
Posts: 295
    
    5

It might get more common now that we have HTML 5.1 in progress. Of course no-one really took to calling HTML4 "HTML 4.01".
 
Don't get me started about those stupid light bulbs.
 
subject: disable button in html 5.0 with javascript based on one-four variables example