Topic: Fun with the DOM -- setting <button> type Pages that link to <a href="https://ozoneasylum.com/backlink?for=22214" title="Pages that link to Topic: Fun with the DOM -- setting &amp;lt;button&amp;gt; type" rel="nofollow" >Topic: Fun with the DOM -- setting &lt;button&gt; type\

 
Author Thread
mobrul
Bipolar (III) Inmate

From:
Insane since: Aug 2000

IP logged posted posted 06-17-2004 03:38 Edit Quote

I have a form for registering for training classes. 5 fieldsets:
class info
participant info
button bar
customer's company info
reset and submit buttons

The third fieldset -- the button bar -- consists entirely of <button>s.
They do many DOM manipulation stuff like allow one user to register many people at the same time (by adding a new participant info fieldset dynamically), etc.
Anyway, I only want the button bar to be created if the brower is capable of doing the things the buttons do. So, I create the fieldset with some js&DOM onload. If the client doesn't understand how to use the buttons, it won't understand how to build them in the first place.
Wonderful.

My problem is, the buttons are created with type='submit' by default. There are two other options, 'reset' and 'button'. I'd like to set the type='button' so I can attach onclick events to do what I want. No can do, my browsers tell me -- type is readonly.

Is there a way I can create the buttons with type being button rather than submit?

If not, is there another solution?
I tried adding onsubmit event, which did the actions I want and always returned false...hoping that would stop the submit action.
That didn't work either. Seemed the buttons just ignored the rest of the function and the form ignored the return false and submitted the form anyway.

I'm stuck. Any help would be greatly appreciated.

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

IP logged posted posted 06-17-2004 08:54 Edit Quote

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

IP logged posted posted 06-17-2004 19:33 Edit Quote

I wrote a bit of code that simulates a button that is created dynamically. It is a 3 image based button that switches state following the up, hover, and down events. The onclick event can be redirected to any function on the page as well. That could be a way to go on this. I remember trying to create some form elements on the fly and I ran into all sorts of trouble so that is why I ended up creating this button code to get around it. If you think that sort of thing may be useful then I would be more than happy to show you how I did it and maybe you could tailor it to your needs.

: . . DHTML Slice Puzzle : . . . : Justice 4 Pat Richard : . .

mobrul
Bipolar (III) Inmate

From:
Insane since: Aug 2000

IP logged posted posted 06-17-2004 20:33 Edit Quote

I thought innerHTML was only for the contents, not the attributes. Seems I need to do more reading about that.

In the meantime, Bugs, let's see what you got. I'm interested and desperate.

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

IP logged posted posted 06-17-2004 20:49 Edit Quote

It would be interresting to hear Slime talking about the creation of form fields with the DOM. I remember he had some problems with some bugs in IE while he worked on the GUI of his 2nd JavaScript Raytracer.

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

IP logged posted posted 06-17-2004 21:20 Edit Quote

Take a look at this page: http://www.bugimus.com/dhtml/bugLib/bugLib1.0%20Test/bugButton.html

A slightly more descriptive page for the other modules is here: http://www.bugimus.com/dhtml/bugLib/

I'm tyring to work on a collection of javascript objects that all work nicely together and when you look at the code, there will be a fair amount of overhead in it. So do a "save as" and take a look at each of the js files that I include on this page to get the full picture.

I'm sure it can be stripped down to a compact version to fit your needs if you decide it will do what you want. If you would like any help with any of it just let me know.

poi, please go easy on me. This library is very much a work in progress and I hadn't planned on revealing much of it just yet. But if do have any feedback, I'll gladly take it all the same

: . . DHTML Slice Puzzle : . . . : Justice 4 Pat Richard : . .

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

IP logged posted posted 06-18-2004 00:24 Edit Quote
quote:
Bugimus said:
poi, please go easy on me.

what does it mean ? I'm not a croquemitaine ( the French version of the "bogeyman" ).
Your code looks nice. The only thing that puzzles me is that you base your cross browser ( backward ) compatibility on a browser detection instead of a ( forward compatibiliy based on ) property detection. For instance I would write the getoOpacity() that way :

code:
function getoOpacity()
{
if( this.style )
{
if( this.style.opacity )
return this.style.opacity // css3 version
if( this.style.MozOpacity )
return this.style.MozOpacity
}
if( this.filters && this.filers.alpha && this.filters.alpha.opacity )
return this.filters.alpha.opacity
return 1
}

But it's certainly not the best way.

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

IP logged posted posted 06-18-2004 00:38 Edit Quote

poi, I didn't mean anything against you at all, just the opposite actually (whether or not you're a croquemitaine is perhaps a subject for another thread ) I was expressing my own insecurity since I don't have as much time anymore to devote to keeping up the latest scripting techniques. I appreciate your peer reviewing.

Anyway, I think I haven't fully thought out the browser sniffing issue. I will bring this up in the dhtml forum more when I get closer to working on that more. I value very highly the input that you, InI, and others offer over there.

mobrul, I hope this is not too far afield from what you need.

: . . DHTML Slice Puzzle : . . . : Justice 4 Pat Richard : . .

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

IP logged posted posted 06-18-2004 08:05 Edit Quote

I looked at my methods a little closer and I must say that I don't have a good reason for using browser detection instead of property detection. A long time ago, I did a little of both methods but I just got into the habit of detecting browsers and never put much more thought into it since that time. I will reconsider that as I continue to develop this collection of code.

Hey mobrul! Where you be? How are things coming along?

: . . DHTML Slice Puzzle : . . . : Justice 4 Pat Richard : . .

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

IP logged posted posted 06-18-2004 09:24 Edit Quote

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

IP logged posted posted 06-18-2004 12:18 Edit Quote

InI+Bugimus: yep, browser or object detection is questionnable. Not so long ago I used browser detection because the real problem was the backward compatibily. But with the recent boost of activity in the browser world, I tend to think in term of forward compatibiliy. Many sites were broken when Netscape 6 came out. On one hand it generated some contracts to fix them, but it also put some doubts on the companies who did those sites in the first place as the problems were avoidable.

InI: Thank you bunny .

mobrul
Bipolar (III) Inmate

From:
Insane since: Aug 2000

IP logged posted posted 06-18-2004 15:11 Edit Quote

Bugs, that's slick. I dig it.
I think, for sure, this'll be something I can use...and it won't take much modifying at all.
I got pulled off onto another little PHP-COM-excel issue, but will be back to this DOM (or damn...) thing full-speed this weekend.
Thanks.

InI, I see now what you mean.
I was looking at the issue, perhaps, a bit too narrowly.
What are the compatibility issues if innerHTML? Anything in particular I need to watch for?

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

IP logged posted posted 06-18-2004 22:41 Edit Quote

Sweet. I will be out of town this weekend but I will be online via dialup for some of that time. I would very much like to chat with you if we get online at the same time.

About innerHTML, the main problem with it is that it is still a non-standard hack. Don't get me wrong, I love it to death but if the W3C doesn't bless it, then we really should try to avoid it. I'm sure InI can elaborate more on the pitfalls associated with it.

: . . DHTML Slice Puzzle : . . . : Justice 4 Pat Richard : . .

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

IP logged posted posted 06-19-2004 23:25 Edit Quote

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

InI
Maniac (V) Mad Scientist

From: Somewhere over the rainbow
Insane since: Mar 2001

IP logged posted posted 06-20-2004 12:51 Edit Quote

The poster has demanded we remove all his contributions, less he takes legal action.
We have done so.
Now Tyberius Prime expects him to start complaining that we removed his 'free speech' since this message will replace all of his posts, past and future.
Don't follow his example - seek real life help first.

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

IP logged posted posted 06-20-2004 15:15 Edit Quote

Now that is a very interesting page! It really pissse me off that I've been spending so much time learing the "right" way of doing things when it is so $%&&#@#@ slow!!! Ugh...

I had wanted to try the cloning method to see if that would help and now I see even that is going to yield minimal improvements.

: . . DHTML Slice Puzzle : . . . : Justice 4 Pat Richard : . .

poi
Paranoid (IV) Inmate

From: France
Insane since: Jun 2002

IP logged posted posted 06-20-2004 16:09 Edit Quote

That's in those moments that I appreciate the many hours I spent working on my raycasting engines in JavaScript trying to find the optimal method for every part of them.

Bugimus
Maniac (V) Mad Scientist

From: New California
Insane since: Mar 2000

IP logged posted posted 06-20-2004 17:08 Edit Quote

I just hate being torn between "standards" and reality. You know?

: . . DHTML Slice Puzzle : . . . : Justice 4 Pat Richard : . .



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu