Skip to main content
22 votes

Updating dimensions when focus is lost from any of 9 columns

I don't do C# so pardon the syntax, but you should be able to reduce the amount of code by using a for loop over a string array with your column names. Again I don't do C# but in Java you could do ...
Emily L.'s user avatar
  • 16.6k
15 votes
Accepted

Updating dimensions when focus is lost from any of 9 columns

A shorter version would be to create an anonymous array in the if statement combined with a collection initializer where you will add all of the column names and ...
Denis's user avatar
  • 8,508
10 votes

Selecting checkboxes based on URL parameters

Extract the chk parameter value from location.search and use a "lookup table" object: ...
woxxom's user avatar
  • 1,952
7 votes

Selecting checkboxes based on URL parameters

First of all, it would help tremendously if you named the URL parameter values and the form element IDs consistently. Why do you have chk=webdes-check ...
200_success's user avatar
7 votes

JS Function warning before closing browser

If you don't need the confirmExit function anywhere else, you can just assign it to to window.beforeunload. ...
Cedric's user avatar
  • 331
7 votes

Simple checkboxes with React

I think everything Sam Onela said is great. I'm gonna add a few more things. Don't modify your state directly In general, it's considered bad practice to directly modify your state object. According ...
Simon Baumgardt-Wellander's user avatar
7 votes
Accepted

PHP HTML form Class - so far so good?

I have not conducted a deep review of your scripting, but I have a few pieces of superficial advice: Study PSR-12 coding standards and obey every rule. This will make your code easier for you and ...
mickmackusa's user avatar
  • 8,674
6 votes

Upload an image to a folder through a form

You should invert the order of your PHP processing and your HTML output. When working in PHP, always strive to adhere to this approach, as it will help you as you start working on more complex logic. ...
Mike Brant's user avatar
  • 9,618
6 votes
Accepted

HTML form using <table> or <div>

Specification In the HTML specifications you can find the following: The HTML table model allows authors to arrange data -- text, preformatted text, images, links, forms, form fields, other tables,...
insertusernamehere's user avatar
6 votes

Selecting checkboxes based on URL parameters

I don't do javascript but what I noticed right away is that you are doing url[1].toLowerCase() for each if and ...
Heslacher's user avatar
  • 50.4k
6 votes
Accepted

Counting characters inside of a textarea using Angular

You don't need to declare an extra reference variable. I would suggest the first approach i.e. using [(ngModel)] for two-way data binding. However, in the first ...
FAISAL's user avatar
  • 176
6 votes
Accepted

Address form validation

Instead of individual variables, you should use an array. ...
Roland Illig's user avatar
  • 21.3k
6 votes

PHP HTML form Class - so far so good?

You could make it much more simpler to read if you use templating engine. Rendering HTML right inside php is something many experienced developers try to avoid for multitude of reasons. One of them ...
slepic's user avatar
  • 5,487
5 votes
Accepted

Upload an image to a folder through a form

The first thing I saw when I looked at your code was the obvious disregard to any kind of indentation! It is nearly unreadable! There's no excuse to have a code without any indentation. Throwing the ...
Ismael Miguel's user avatar
5 votes

Mask latitude text field

Unless you know for sure that the degrees, minutes, and seconds are always going to be 2 digits each, this approach will cause issues. I would recommend using 3 separate inputs for each value and ...
I wrestled a bear once.'s user avatar
5 votes
Accepted

HTML Date Selector

I didn't pay much attention to your logic, but focusing on this question: Can you elaborate on how you would separate this into a javascript class? I like the idea of reusability, but how would you ...
I wrestled a bear once.'s user avatar
5 votes

JS Function warning before closing browser

You have defined the variable formmodified as a global variable. This means that it can be modified from anywhere using the code ...
Roland Illig's user avatar
  • 21.3k
5 votes
Accepted

Calculate Final Grade: follow-up

I went ahead and refactored your code a lot. However, before I get into that, lets talk about what you did and what you could have done differently. Feel free to let me know if you want me to expand ...
kemicofa ghost's user avatar
5 votes

PHP function that clones HTML form structure to MySQL database structure

It looks like you are throwing caution to the wind here. I mean you are granting full control of your database structures to the end user and offering the raw mysqli errors when they arise. These ...
mickmackusa's user avatar
  • 8,674
5 votes
Accepted

OOP PHP form builder with validation

This looks like proper OOP code. It doesn't just encapsulate a lot of functions in a single class. It's expandable with more input types and errors, but I am afraid that you might have overdone it a ...
KIKO Software's user avatar
5 votes

OOP PHP form builder with validation

OOP I agree with the answer by Kiko. You didn't ask about MVC code but if that is a goal then it would be wise to only have HTML/text output by the view components - e.g. either in FormGenerator.php ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
4 votes

PHP login form with PDO

Always authenticate the user before you take any restricted action. In login.php you have: ...
BeetleJuice's user avatar
4 votes
Accepted

Registration form validation in jQuery

Here is my take, dry some stuff. You can glue each piece of code together to have a working script (I guess). Keep track of your validations ...
Hugeen's user avatar
  • 303
4 votes
Accepted

Instantaneous validation of form field length

Ternary operator You could use the ternary operator for your first if-else case: ...
Craig Ayre's user avatar
4 votes
Accepted

Changing form display based on selected values

Before getting into the code, I would suggest reading this article Stop writing slow Javascript. It has some good techniques for reducing time needed for DOM/page interaction. And while it is over 9 ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
4 votes

JS Function warning before closing browser

Is this the most efficient way to do this function? For the sake of efficiency, what you have may be close. As others have pointed out, the selector for the fields to reset the value of ...
Sᴀᴍ Onᴇᴌᴀ's user avatar
4 votes

Insert contact information from form fields into MySQL database when button is clicked

Not showing ConnectionString in plaintext. I currently store it in App.Config and I am still trying to figure out how to encrypt it. Anything you can decrypt locally, a malevolent (and sufficiently ...
Flater's user avatar
  • 5,542
4 votes

onChange vs onKeyPress for input in React

Don't complicate your code; the first solution is just fine but needs some tweaking: ...
Devdahcoder's user avatar
4 votes
Accepted

Dynamic country, state select options

There are 4 different places in the code, where you do something for every country. That makes it complicated to add more countries, and also makes the code very long if you have many. But you can get ...
Kruga's user avatar
  • 1,124

Only top scored, non community-wiki answers of a minimum length are eligible