PDA

View Full Version : would it be possible to create my own form-elements with JS ?


peakss
09-11-2002, 12:18 PM
I was just on a lesson and my thoughts just ran away for a while.
And then I started look at some sites, an that was then the it crossed my mind;
Would it be possible to create my own form-elements with JavaScript/DHTML ?

Instead of using the boring drop-down menu(<SELECT>) or the boring radiobuttons/checkboxes and so on, would it be possible to script my own ones and use them instead ??

thanks|Peakss

piglet
09-11-2002, 12:37 PM
Hi peakss,

Yes - sure you can create your own things on the fly - Just use the new() operator.

It's a bit of a pain to do this sort of thing to work cross-browser (Netscape 4 doesn't show new form elements until you go a history.go(0) - and that clears the form contents)

Most people don't bother as it's just a pain in the...

There's a N4 example on this link (http://developer.netscape.com/docs/manuals/js/client/jsref/option.htm)

peakss
09-11-2002, 01:12 PM
Hmm, thank you for your reply, but it's not what I want.

Instead of using the SELECT-tag I could use a dynamical dropdown menu found at dynamic drive or something. That's more what I want. I want to know if it is possible to do the same thing with textfields, radiobuttons as well.

The point of this is that I want to create my own form elements, NOT use the already existing ones.

Say that I create a new checkbox script that displays one image when ticked, and one other when unticked. I have seen this but I dont remeber where...

This probably won't be able to do cross-browser compatible but I just want to know if it's even possible to do in IE.

I know I'd have to do scripts for events such as mouseover, mouseclick and so on for each formitem I decide to create.

So basicly, what I'm after is a page that has no form-tags what so ever, only my calls to my form-scripts (they will work the same as regular form-elements but will look totally different)

I doubt this is possible to do with every element, but I have seen checkboxes/radiobuttons and dropdown menus that works the same. But I guess it will require A LOT of time to accomplish this.

thanks|Peakss

jkd
09-11-2002, 02:01 PM
If you write your widgets as DHTML effects, the only way to reflect the user's choices to the server when submitting would be to "copy" their selected values over to <input type="hidden" value='bla"/> elements onsubmit.

peakss
09-11-2002, 02:14 PM
yay!
:)

I know I have to 'copy' the values to hidden fields but that's way a head into the future. :D

Radiobuttons, checkboxes, dropdown menus wont be any problem but I'm sure textfields and textareas will be hard to implement. Especially if the user decides to edit what he/she just typed in.
The usual button for editing/correcting is the backspace-key, and in IE it transfers the user to the previous page...

thanks|Peakss