Post by nde » Sun Feb 15, 2009 10:00 am

I noticed that most form submits are handled with onclick javascript. In my humble opinion, this is a terrible choice. The result is that the site visitor can't just enter data into forms and press enter (for searches, logins etc.). He needs to grab the mouse to submit the form.

Don't you think a non-javascript method is a much better choice?

nde
New member

Posts

Joined
Sat Jun 30, 2007 7:32 am

Post by Daniel » Sun Feb 15, 2009 10:16 am

No because the searchs are more of a filter which needs to be built up depending on which fields have been clicked or not. Its hard to explain but suing standard forms to filter data is causes problems.

what you can do is set the javascript to submit when enter is pressed when the search field is selected.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by nde » Mon Feb 16, 2009 10:22 am

Hmm, but that's a developer point of view, without the user in mind. I'm not complaining. But I think it's really the center point of a website that's gonna be used by a wide/general audience of users (like a shop script). Ok it's 2009 already and websites are rather applications. But a simple search etc. is not so fancy. I tested the script with my sister and even she found that irritating. Even Gmail works without Javascript, not to forget about eBay or Amazon...

nde
New member

Posts

Joined
Sat Jun 30, 2007 7:32 am

Post by Daniel » Mon Feb 16, 2009 6:50 pm

i will fix it later. All i i do is set it so when eneter is pressed it submits the form.

Its not about setting buttons to use javascript its about pressing enter to submit the form.

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by nde » Tue Feb 17, 2009 3:02 am

What I meant is that any site should degrade gracefully and work without Javascript.
It's fully your decision of course, I suck at PHP (only do UI development and xhtml/css at work) so I don't know if it's possible, but I really think it's a must for modern web dev.
http://en.wikipedia.org/wiki/Unobtrusive_JavaScript

Are you looking for more feature suggestions? I set up a few shops for different kind of businesses - using Magento (the horrors), Cubecart, Prestashop etc. I made a rather big list of feature ideas etc for a shop during the recent two years.

nde
New member

Posts

Joined
Sat Jun 30, 2007 7:32 am

Newbie

Posts

Joined
Fri Feb 20, 2009 7:34 pm

Post by liquidpele » Tue Feb 24, 2009 12:04 am

Daniel,

To make the enter button work, you can do one of two simple thigns:

1) Add a listener on the field like so:

<input type="text" onKeyDown="if(event.keyCode==13){submitfunction();}">

2) Add a <form> tag around the input like the following:

<form onSubmit='submitfunction(); return false;'>

That makes it not refresh the pages because of the "return false" but instead simply runs the submitfunction()


It would make it a lot nicer to be able to use the enter key.

New member

Posts

Joined
Mon Feb 23, 2009 11:58 pm

Post by nde » Tue Feb 24, 2009 3:20 am

I place my neck on the table and still say: Javascript should not be inline. It should be external and add behaviour. And there must be a fallback solution of course. That's a no brainer for modern web development. It would be acceptable in the backend, but not on the front end. Especially not on any E-Commerce site.

Daniel: is it even possible to make it work without Javascript? I would like to use Opencart for future carts that I set up. So I'm considering paying a PHP dev to make it work. I can't do myself because I'm a PHP noob.

nde
New member

Posts

Joined
Sat Jun 30, 2007 7:32 am

Post by Daniel » Tue Feb 24, 2009 6:49 am

nde wrote:I place my neck on the table and still say: Javascript should not be inline. It should be external and add behaviour. And there must be a fallback solution of course. That's a no brainer for modern web development. It would be acceptable in the backend, but not on the front end. Especially not on any E-Commerce site.

Daniel: is it even possible to make it work without Javascript? I would like to use Opencart for future carts that I set up. So I'm considering paying a PHP dev to make it work. I can't do myself because I'm a PHP noob.
Hi nde,

I don't mean to be rude but if you need to pay a web developer to do these alterations for you does that mean you don't know HTML and Javascript?

Every web 2.0 application uses JavaScript. I don't like Javascript, but its the only dynamic language available. Why do you think onclick, onfocus, onmousemove, etc.. are in HTML and defined in the W3C.

User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by codecreator » Tue Feb 24, 2009 7:48 am

Daniel,

What I think he means is that the trend is toward unobtrusive javascript instead of inline. I am no javascript expert, but have been modifying current projects to use unobtrusive javascript based on some good examples I've found online. It certainly makes for a cleaner markup and is also more consistent with good programming practice of separating functionality from presentation.

New member

Posts

Joined
Mon Aug 04, 2008 6:39 pm

Post by Qphoria » Tue Feb 24, 2009 8:29 am

I also tend to agree. Leaving the page untouched and then using javascript to manipulate it based on id and class is the more favorable method.

User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by nde » Wed Feb 25, 2009 4:56 am

Daniel wrote:
nde wrote:I place my neck on the table and still say: Javascript should not be inline. It should be external and add behaviour. And there must be a fallback solution of course. That's a no brainer for modern web development. It would be acceptable in the backend, but not on the front end. Especially not on any E-Commerce site.

Daniel: is it even possible to make it work without Javascript? I would like to use Opencart for future carts that I set up. So I'm considering paying a PHP dev to make it work. I can't do myself because I'm a PHP noob.
Hi nde,

I don't mean to be rude but if you need to pay a web developer to do these alterations for you does that mean you don't know HTML and Javascript?

Every web 2.0 application uses JavaScript. I don't like Javascript, but its the only dynamic language available. Why do you think onclick, onfocus, onmousemove, etc.. are in HTML and defined in the W3C.
Hi Daniel,

yes many web apps use Javascript, but most of them fall back nicely and work without Javascript too. Like I wrote above, even Gmail works without Javascript.
The thing is that there are people coming to a shop with a browser where Javascript just won't work. They are in the total minority, but in my eyes they can't be ignored.

Sure there are JS events defined in the W3C spec, but using them on sites targeted for end users is considered bad practice among people who build web sites. I would say this is similar to how PHP devs look at Register Globals or sticking to PHP5 now and things like that.

When I said I'm considering to pay a developer, I meant that I couldn't do these changes to the script myself. I am very firm in XHTML/CSS and making user interfaces, but not PHP.


Fyi: the current front end for the cart is broken in IE 6 and below (25% - 35% of users according to various stats). Maybe that's because you use a xml declaration which causes IE to render the site in quirks mode.
I'm making a new template which works in IE 5.0 and major browsers on Linux and Mac OS too.

nde
New member

Posts

Joined
Sat Jun 30, 2007 7:32 am

Post by SiteE@se » Thu Apr 16, 2009 6:20 pm

Just in case it may be of help to anyone else, a customer insisted that he just had a plain quick search box that would submit on pressing enter (NO button wanted!) I've used this in template->common->search.tpl but it might be improved upon:

Code: Select all

<div>
  <?php if ($keyword) { ?>
  <input type="text" name="keyword" value="<?php echo $keyword; ?>" id="filter_keyword" onclick="this.value = ''" onChange="getsearch();"/>
  <?php } else { ?>
  <input type="text" name="keyword" value="<?php echo $text_keywords; ?>" id="filter_keyword" onclick="this.value = ''" onChange="getsearch();" onblur="if(this.value=='') this.value='<?php echo $text_keywords; ?>';" onfocus="if(this.value=='<?php echo $text_keywords; ?>') this.value='';"/>
  <?php } ?>
</div>
<script type="text/javascript"><!--
function getsearch() {
	url = 'index.php?route=product/search';
	
	var keyword = $('#filter_keyword').attr('value');
	
	if (keyword) {
		url += '&keyword=' + encodeURIComponent(keyword);
	}
	
	location = url;
}
//--></script>

Active Member

Posts

Joined
Mon Dec 17, 2007 7:40 am
Location - UK

Post by make-oc » Mon Apr 20, 2009 3:32 pm

Oh well on one hand people campaign against IE6 which may be used by a good number of users and on the other hand people worry about a small number who don't have JS in their browser – so just make a decision for yourselves who your audience is and use IE fixes and NoScript Tags to please most or all of them, I'd say.

Not much of a PHP/Ajax person myself, but doing ok… I'd say best practice is to develop the application based on Forms using POST without any JS and then apply your jQuery etc. to make it nice and hip, as well as functional. I'd say this is what nde wants someone to do for him… myself, codecreator and Qphoria agree on would be a nice thing for future releases.

I'm rather into Html/CSS/Usability and have some issues with OC regarding this — so maybe there'd be away to work all together on this?

Cheers

New member

Posts

Joined
Tue Apr 07, 2009 2:17 pm

Post by Daniel » Mon Apr 20, 2009 6:42 pm

problem is youi con't have nice buttons if you don't use javascript.

User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by SiteE@se » Mon Apr 20, 2009 6:58 pm

Daniel wrote:problem is youi con't have nice buttons if you don't use javascript.
Really? Surely you can use a fancy button, styled with css if it is placed within it's own fieldset in a traditional form?

Active Member

Posts

Joined
Mon Dec 17, 2007 7:40 am
Location - UK

Post by Qphoria » Mon Apr 20, 2009 7:23 pm

SiteE@se wrote: Really? Surely you can use a fancy button, styled with css if it is placed within it's own fieldset in a traditional form?
Well the design here is that the buttons are all using 1 background image with actual text as a link... and just stretching across the span. As opposed to using actual images, which would mean 1 image for each button.

It is a shame HTML never created an input type="link" or something that allowed this natively. All input types should be allowed to be a "submit" button imo. Then things like like submit on select and radio change would also be native

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by SiteE@se » Mon Apr 20, 2009 8:17 pm

Qphoria wrote: Well the design here is that the buttons are all using 1 background image with actual text as a link... and just stretching across the span. As opposed to using actual images, which would mean 1 image for each button.
Entirely possible with the form/fieldset/css solution ... use the 'sliding doors' technique of CSS, plus two sliced background images with "on" and "off" states, to create flexible shaped CSS buttons. Each button can accommodate text of variable widths.

Chris

Active Member

Posts

Joined
Mon Dec 17, 2007 7:40 am
Location - UK

Post by Qphoria » Mon Apr 20, 2009 9:21 pm

SiteE@se wrote:
Qphoria wrote: Well the design here is that the buttons are all using 1 background image with actual text as a link... and just stretching across the span. As opposed to using actual images, which would mean 1 image for each button.
Entirely possible with the form/fieldset/css solution ... use the 'sliding doors' technique of CSS, plus two sliced background images with "on" and "off" states, to create flexible shaped CSS buttons. Each button can accommodate text of variable widths.

Chris
I assume you are talking about something like the example towards the bottom of this link:
http://cssbutton.com/forms/

It's ugly to use that much code tho... maybe feasible. but eh. Tho I see his "submit" button image isn't stretching well.

I actually created a jscript that
- finds all input type="button"
- gets the "value"
- replaces the button with a text link, using the value for the link
- and styles the button

This way when javascript is enabled, you see the pretty button
When jscript is off, you see the standard gray button.

A bit overkill i guess.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by SiteE@se » Tue Apr 21, 2009 12:30 am

Qphoria wrote: I assume you are talking about something like the example towards the bottom of this link:
http://cssbutton.com/forms/

It's ugly to use that much code tho... maybe feasible. but eh. Tho I see his "submit" button image isn't stretching well.
There are also examples at http://www.dynamicdrive.com/style/cssli ... tegory/C7/ with well-commented (although slightly bulky) code.
Qphoria wrote: I actually created a jscript that
- finds all input type="button"
- gets the "value"
- replaces the button with a text link, using the value for the link
- and styles the button

This way when javascript is enabled, you see the pretty button
When jscript is off, you see the standard gray button.

A bit overkill i guess.
With jscript the code still has to be rendered on the client side - There's probably only milliseconds in it but I'm not sure which solution css or javascript is actually the most efficient. Assuming the css is in a separate file it will be cached (as would jscript). However, not all javascript used in OC 1.2.6 (AFAIK) is stored in external files and some therefore isn't cached, which must slow things a little?

Active Member

Posts

Joined
Mon Dec 17, 2007 7:40 am
Location - UK
Who is online

Users browsing this forum: No registered users and 4 guests