onclick="document.getElementById('changeDefault').style = 'visible'" not working
hey. this not a pretty script right now but in this moment it doesnt matter. I'm trying to unhide a <div id="changeDefault> and then rehide it after, but the unhiding won't work, i keep getting a "member not found" js error. any ideas?
(also if anyone wants to take a shot at helping with the actual JS script i'm trying to write in there, by all means)
thanks
Code:
<style type="text/css">
.white {
background-color: #fff }
.blue {
background-color: #ccf }
.red {
background-color: #fcc }
.green {
background-color: #cfc }
.yellow {
background-color: #ffc }
</style>
<script language="JavaScript">
var chosenColor = saveClass(this.class)
function applyClass() {
document.getElementById('this.id').class = "+chosenColor+"
}
function finalChoices() {
usersDefaults = new array[]
// save every newly made choice into this array, and this is what gets saved and used by the PHP tbale to determine what shows as what
}
</script>
<body>
<div align="left"><a href="#" onClick="document.getElementById('changeDefault').style = 'visible'; return false">Change the default state</a>
</div>
<div id="changeDefault" style="visibility: hidden" align="center">
<table id="applyColor" border="1" cellpadding="0" cellspacing="0">
<tr>
<td onclick='applyClass()' align="center" id="work"> At Work </td>
<td onclick='applyClass()' align="center" id="class"> In Class </td>
<td onclick='applyClass()' align="center" id="defAvail"> Definitely Availiable </td>
<td onclick='applyClass()' align="center" id="posAvail"> Possibly Availiable </td>
<td onclick='applyClass()' align="center" id="sleeping"> Sleeping </td>
</tr>
</table>
<br>
<table id="selectColor" border="1" cellpadding="0" cellspacing="0">
<tr>
<td width="20" onclick='saveClass(this.class)' align="center" class="white"> </td>
<td width="20" onclick='saveClass(this.class)' align="center" class="blue"> </td>
<td width="20" onclick='saveClass(this.class)' align="center" class="green"> </td>
<td width="20" onclick='saveClass(this.class)' align="center" class="red"> </td>
<td width="20" onclick='saveClass(this.class)' align="center" class="yellow"> </td>
</tr>
</table>
<br>
<div align="center">
<input type="button" value="Save" onClick="usersDefault(); document.getElementById('changeDefault').style = 'hidden'" id="userDefaultButton">
</div>
</div>
What i'm really trying to achieve is to have users click once on the table below, and then click in a cell above and have it apply the class of the table they first clicked to the cell of the second. once they apply the class to one cell they have to select another color to apply it to another cell
__________________
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)
Last edited by canadianjameson; 06-09-2005 at 03:10 PM..
I need to make a few minor changes, and then it will be exactly how I need it.
Okay, here's how this is going to be used.
Before the user even clicks the link to unhide the tables, default colors/classes for each state (sleeping, etc) will already be set.
When the user opens the link, its to change the default colors
The first change is that there can only be one of each color on the table... so if for example they want to switch Red and Green, if they choose the Red from the 2nd table (id="setColor") and click on the green cell on the first table (id="applyColor"). In addition to that, i need the 2nd red square (the one which was loaded as red when the table opened) to turn gray. let me illustrate with a 3 cell example
Code:
it opens like this
| At work | In Class | Definitely Availiable |
| Red | Green | Blue |
-----------------------
the user clicks on the Blue and then applies it to the In Class cell.
This is what I need to happen
| At work | In Class | Definitely Availiable |
| Red | Green | Blue |
Because there can only be one of each color, the duplicate color goes to Gray.
Finally, if there are any gray squares on the table when the user hits save, i need a simple msg (either JS alert or unhidden Div) to appear telling them that they must choose a state for (whatever state is unchosen/gray)
would this be hard to acheive?
P.s: also, because these values are being passed to PHP and used... if the user opens the link again later on, the defaults they have just chosen would be displayed in the table. I thought I should mention that now since it may impact how it is coded.
__________________
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)
Last edited by canadianjameson; 06-09-2005 at 10:48 PM..
__________________
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)
i added a center to the <div id="changeDefault" align="center"> and i wanted to know. is it possible to easily line up the "Save" button with the left edge of the applyColor table? its just aesthetics but i figured i should ask incase theres a simple way to do it.
here's another purdy visual:
Code:
what I have now is
| Blah Blah | Woof Woof | Meow |
| colors to choose |
Save
what i would like is: :o)
| Blah Blah | Woof Woof | Meow |
| colors to choose |
-
Save
if this is difficult to do then forget it, i just thought there might be an easy one-line solution
__________________
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)
Last edited by canadianjameson; 06-10-2005 at 02:45 PM..
ahahah. you know those words you just CANT spell properly no matter what you do... thats one of them for me. thanks for the heads up, i might actually remember now.
I like the CSS align center, i was looking for it but i couldn't it so i took the lazy way out. the aligning of the save button to the left side of the table doesn't seem to have worked though... any ideas?
Edit:
I actually thought you'd have to use JS to get the top table's position on the window. From that you could deduce the position of the tables left border, and apply that position to the Save button. Then again I could be crazier than a drunken goat...
__________________
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)
Last edited by canadianjameson; 06-10-2005 at 04:29 PM..
hahaha awesome. Thats okay, i had a feeling that might happen... i kept trying to get the whole code to display but it wouldn't
how do you get that table around your EDIT? i so wanna steal that
__________________
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)
__________________
Before you criticize someone, you should walk a mile in their shoes. That way, when you criticize them, you're a mile away and you have their shoes :)