Archived

This topic is now archived and is closed to further replies.

Evil Bill

HTML & &#106avascript

Recommended Posts

Hi, I've got my own little forum system going, and it allows you to choose what colours certain parts of the forum are (background, text, table colours, etc.). At the moment, for each customisable colour, i allow the user to select a radio button from a group of 64 possibles, or to enter a custom colour (as a RRGGBB value). Most people who use my forum don't know how to use HTML, let alone convert yellow to hex or whatever, so i'd like to keep the large number of possible colours. The problem is the size of the HTML file. You can see it Here, all 164Kb of it... I was thinking, is it possible to have a button on a forum ("Pick" or something), so instead of having all the radio buttons, i'd have them on another HTML document. Then to choose the colour, you'd click the 'Pick' button, a popup window would open, and then when you click on another button ('Done' or whatever) on the popup window, it would close and fill in a field on the original document. Is that possible? Sorry for my crap explanation. What i'm trying to say is, is it possible to make a popup window, and then modify a value on the parents document? I've only used javascript for basic stuff (Although i did a year of Java at uni), so i'm probablt missing something obvious. Edit: forgot to mention, this is all done with C++ CGI if that matters at all. Also, if you look at the source, you'll see <TBODY> tags in it, and also its indented. Anyone know where that came from? I certainly didn't put it there... Cheers [edited by - Evil Bill on December 24, 2002 8:47:47 AM]

Share this post


Link to post
Share on other sites
Ok, it works perfectly:

  
function OnDone()
{
for(i=0; i<ColourList.RadioItem.length; i++)
{
if(ColourList.RadioItem[i].checked)
{
if(ColourList.RadioItem[i].value == ''X'')
window.opener.document.ColourForm1.ColourText.value = ColourList.RadioItemText.value;
else
window.opener.document.ColourForm1.ColourText.value = ColourList.RadioItem[i].value;
window.close();
return true;
}
}
}


New question: Is there a way to pass a value to this popup window? Because ive got over 10 different fields on the first HTML document that all need colours picked. The way i do it above is to set window.opener.document.ColourForm1.ColourText.value, but ColourText may be ColourBack, ColourTable, etc etc. Can i pass an input box to the popup window somehow?

Share this post


Link to post
Share on other sites
From a user interface point, while the popup window is nice I wouldn''t call it the final solution to your problem. Large numbers of radio buttons are still bad, plus, as you mentioned, the hex entry is no good for a lot of people. What I might suggest is creating an image (color gradiant) with a javascript function to tell where they clicked on it and change a preview box to the correct color (much like the Windows color picker).

Share this post


Link to post
Share on other sites
quote:
Original post by Evil Bill
Hmm... never thought of the colour gradient idea...
I''ll take a look at that methinks.

Thanks for the suggestion!




http://javascript.internet.com/miscellaneous/color-cube.html

Not a super pretty version, but it works.

~"What''''s this red button do?"

Share this post


Link to post
Share on other sites