View Full Version : Javascript novice in need of help

08-24-2007, 08:52 PM
Hi. I'm a little clueless about Javascript, so I need some help.

What I want to do is create a page where a user can get a customized snippet of HTML that has user-chosen stuff through a color picker and drop-down menus, and then either display the result in a textarea, or better yet, send the code directly to another website's (not my own) form fields automatically (although I don't think it can be done, but it doesn't hurt to ask).

The page the user sees can only use HTML & Javascript, unfortunately. I'm using Adobe AIR (Apollo) to make this project but I don't have the slightest clue how to use Flash or Flex or actionscript, so I'm using the HTML/Javascript method.

Anybody know how I could accomplish this?

08-24-2007, 09:58 PM
What I want to do is create a page where a user can get a customized snippet of HTML that has user-chosen stuff through a color picker and drop-down menus, and then either display the result in a textarea,

That didn't make quite enough sense for me to figure out what you actually want to do. Maybe if you do a step-by-step description of what you'd like to have happen?

08-25-2007, 12:43 AM
Yeah - sometimes my fingers go faster than my brain...

What I want to do is create an app that will generate a template for use on Cafepress.com (although this could be used as a simple HTML template too). They should be able to customize it by typing in a title and subtitle, using a color picker (I got the Yahoo one but I haven't tried it yet so I don't know if I'll get it to work) to select the background, foreground and text/link colors, choose fonts, and so on, and then send the resulting code to a text area they can cut and paste out of.

Ideally, it could also send the code straight to Cafepress.com's custom HTML page so the user wouldn't have to enter all the code. But this would require signing in, selecting the correct shop, going to the custom HTML page, filling the forms and submitting it (in a really ideal situation it could backup the existing data). But I don't expect that this would be possible with Javascript, although I really have little clue what you can really do with it. Which is why I'm asking here :)

08-25-2007, 02:59 AM
So...You need help building a script generator? If that's the case, You're going to need someone that a the next few hours/days to spend on helping you. User friendly code generator take a good bit of time to master and you might end up having to pay for the script.


08-25-2007, 04:09 AM
Well, I think I've figured out how to put arbitrary content into a block that you can copy out of. This Google Answers thread (http://answers.google.com/answers/threadview?id=770233) seems to make it look pretty simple. I imagine it won't be too hard to make multiple fields and use text fields for them.

Since I really don't need to do the sending directly to the site part (which would seriously complicate things) all I really need to figure out is how to use that technique with the Yahoo Color Picker (http://developer.yahoo.com/yui/colorpicker/) to insert the color code.

Anyone got any ideas on how to do that? That's all I really need. The code's a bit intimidating at first glance... :confused: Thank you!

08-25-2007, 05:34 AM
Is this contraption of yours going to be submitted and processed by a server side language such as PHP or ASP? I scanned the YUI documentation briefly and found the format of the data that will be passed from the color picker to the server, which you can pick up and use on the server side, if you are planning on a "submit form" aspect of the user interface.

If you want to handle the whole deal via Javascript without submitting to the server.... let me hunt around the docs a bit more and see if I can figure out where the data can be grabbed.

Yeah ok it's a simple matter to get the color value in Javascript and use it for whatever nefarious purpose you have in mind. Look at this link here (http://developer.yahoo.com/yui/examples/colorpicker/colorpicker-fromscript.html) and study the example script. You will notice there is a simple "get" function you can call to retrieve the current color value:

var currentHexColor = picker.get("hex");

You have to first instantiate the picker object, as they do in the example.