Hot answers tagged

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.5k
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,448
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

HTML 5 form validation and form handling

Validating HTML5 Code It seems that you are new to HTML5, so it's a good idea to validate your code. You have 14 errors and 5 warnings in your code: autofocus="on"...
tim's user avatar
  • 25.1k
7 votes
Accepted

Populating many fields in a form using jQuery/AJAX

For starters, you can make compound selectors so this: ...
jfriend00's user avatar
  • 3,938
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,544
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,588
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.3k
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.2k
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,367
5 votes
Accepted

Using actionPerformed() to call different methods per radio button selection

Indeed, the conditional branching in actionPerformed(ActionEvent) is quite complex and prone to bugs. This implementation does too many things at the same time: ...
Antot's user avatar
  • 3,637
5 votes
Accepted

ListFind test conditions

You don't care what the numeric value here is, so don't test for it. You want a boolean, and I think the listFind() call is semantically boolean itself without the ...
Adam Cameron's user avatar
5 votes
Accepted

Keyboard handler for selecting radio buttons

If you are sure it will always have a value just use the charAt value to build the id you try to select in each if block. Something like: ...
AtheistP3ace's user avatar
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.2k
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,544
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

Student registration form

Styling and readability You are using classes as id's, both by not using a class twice or more and by naming them after the specific element you are using the class for. You do not use css-selectors ...
Sumurai8's user avatar
  • 2,595
4 votes

HTML 5 form validation and form handling

Tim's answer addresses most of the problems. In addition to that: Your <label> elements both miss a for attribute, and do ...
Sumurai8's user avatar
  • 2,595
4 votes

Extracting first name, last name, phone number, and address from a form

You could create a method for it! ...
itsme86's user avatar
  • 169

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