So radio buttons are interesting. I'd been trying to come up with a validation would let me check to see if at least one option was selected. The problem is that when the page loads and not options are selected, the value is that set of radio buttons ISN'T null or zero or blank. It's the value of the first option. So all the times I was trying say that is the value is null, give an error message, I was wasting my time. The value is NEVER null. It's just the first one until the user makes a selection.
This threw me for a long while until I wrote a script to tell me in real time what the value was. Once I found out the problem, progress was swift. I placed a placeholder option before the main options, and set it's value to blank. I then set it to display:none, making it invisible. Now on page load, the value IS blank, and so my if statement works.
You can see the test page here.
And I now have everything I need to validate the input for the data table. And 2 hours left of work.
Thursday, June 30, 2011
Input Validation
Earlier this week I created a webpage allowing users to add themselves to my database. A friend of mine was looking at it and found a problem. Instead of telling me though, he decided to show me, by adding 100 blank people to the database.
Input validation! It is necessary. It is also really f***ing difficult to do. I've been researching this for 2 hours and playing around with things, and nothing works at all. I first tried to create a script that would capitalize the first letters of the name inputs, but that failed entirely. Then I tried a more simple goal, checking to see if an input was blank or not. And that's not possible either. Or at least it's not working.
I'm about one more try away from being done, I'll post an update when I reach that.
EDIT (5:06 PM): Alright, I have gotten the name to capitalize correctly. Now to work on the prevention of submission of there are other errors.
Input validation! It is necessary. It is also really f***ing difficult to do. I've been researching this for 2 hours and playing around with things, and nothing works at all. I first tried to create a script that would capitalize the first letters of the name inputs, but that failed entirely. Then I tried a more simple goal, checking to see if an input was blank or not. And that's not possible either. Or at least it's not working.
I'm about one more try away from being done, I'll post an update when I reach that.
EDIT (5:06 PM): Alright, I have gotten the name to capitalize correctly. Now to work on the prevention of submission of there are other errors.
Saturday, June 25, 2011
Congratulations, New York!
New York became the newest state to embrace marriage equality for all, last night. Gov. Cuomo still has to sign the bill, but he has said he will, and it has now passed the full Assembly.
My favorite part of this entire situation was Republican Roy McDonald, who voted for the bill and defended his position by saying "fuck it, I don't care what you think. I'm trying to do the right thing".
Friday, June 24, 2011
Weekly Project - Complete
I set out my goal for this week on Monday. The goal was to take everything I've learned about jQuery, PHP, and SQL over the past month and a half, and use it all to make an interactive data table.
I have accomplished my goal! Check it out.

I actually had 90% of it finished yesterday, and so today was planning on adding a bonus student portal, where students could add themselves to the database. This week is Stars though, at Purdue. That means that the campus is flooded with incoming freshman, all of which seem to need help with setting up their accounts. I got called to another lab to help, and as a result didn't really have much free time. I did manage to do a little tweaking though, and I added 3 select all boxes, one for each attribute.
This weekend, the student portal!
I have accomplished my goal! Check it out.
I actually had 90% of it finished yesterday, and so today was planning on adding a bonus student portal, where students could add themselves to the database. This week is Stars though, at Purdue. That means that the campus is flooded with incoming freshman, all of which seem to need help with setting up their accounts. I got called to another lab to help, and as a result didn't really have much free time. I did manage to do a little tweaking though, and I added 3 select all boxes, one for each attribute.
This weekend, the student portal!
Thursday, June 23, 2011
Another Update
Yesterday night I went ahead and finished the column changing buttons, and got everything working as it would appear to the end user. It was all static though, every name put in by hand.
I came to work today and determined to finish converting to PHP. And I did. That went very quickly actually, because each version of the table became a simple while loop.
The biggest problem though, happened when I needed to get the number of students from the database to my javascript file. This was necessary because the list of students is inside a container div, which has no default height set. If it had a static height, then the list might overflow, of the page might be longer than needed. If it had no height, then when less students are displayed, the header would follow the bottom of the list up, and could overlap with the search panel.
So the height of the container is set each time the page loads as the height necessary to show all students. This is accomplished by using each student's unique ID from the database. I access the max ID, and that is the number of students. Each student is 42 px in height, and the column titles are the same. So the number of students plus 1, times 42, is the total height.
The problem was getting the number of students to the javascript file. I tried using the PHP to set an invisible div's class to that number, and then use attr class in jQuery. But while it would grab the number, say 14, it wouldn't be a number. It would be a character 14.
After about a half hour, I finally moved that section of the jQuery code into the html main doc, and just uses PHP to create the line, num_students = 14;. It is now working, and the last thing I have to do is fix the multiple orders of display.
I came to work today and determined to finish converting to PHP. And I did. That went very quickly actually, because each version of the table became a simple while loop.
The biggest problem though, happened when I needed to get the number of students from the database to my javascript file. This was necessary because the list of students is inside a container div, which has no default height set. If it had a static height, then the list might overflow, of the page might be longer than needed. If it had no height, then when less students are displayed, the header would follow the bottom of the list up, and could overlap with the search panel.
So the height of the container is set each time the page loads as the height necessary to show all students. This is accomplished by using each student's unique ID from the database. I access the max ID, and that is the number of students. Each student is 42 px in height, and the column titles are the same. So the number of students plus 1, times 42, is the total height.
The problem was getting the number of students to the javascript file. I tried using the PHP to set an invisible div's class to that number, and then use attr class in jQuery. But while it would grab the number, say 14, it wouldn't be a number. It would be a character 14.
After about a half hour, I finally moved that section of the jQuery code into the html main doc, and just uses PHP to create the line, num_students = 14;. It is now working, and the last thing I have to do is fix the multiple orders of display.
Wednesday, June 22, 2011
Data Table Update
I spent several hours today working on the visual design and layout of the data table, and am pretty happy with the result. The foot still needs some work, it's sort of just a big blob at the moment, but everything else looks great.
The search panel still works, and either tonight or tomorrow I'll be adding the organize by column effects. It will be the same as I did in the webpage to add data to a table, last week's project, so I just have to use the same method.
Finally then I'll do the PHP, probably on Friday, to finish up the weekly project. Certainly a more ambitious one than last weeks, but understandably given my higher understanding of the languages.
The search panel still works, and either tonight or tomorrow I'll be adding the organize by column effects. It will be the same as I did in the webpage to add data to a table, last week's project, so I just have to use the same method.
Finally then I'll do the PHP, probably on Friday, to finish up the weekly project. Certainly a more ambitious one than last weeks, but understandably given my higher understanding of the languages.
Progress On The Table
It's Tuesday night, and I've spent the past few hours working on my project for the week, the interactive data table. I spent today working out the jQuery code for the search panel, which will show and hide rows depending on which check boxes are selected, without having to reload the page.
I've got that done, and there are 3 different columns in the table that correspond to search options. The tricky part was when clicking a box to unhide a category, getting it to only hide people in that category who were also unhidden with the other 2 categories. It's working now, but the code is sort of clunky, so tomorrow I'll try and figure out a way to cut it down.
Also tomorrow I'll work on the CSS and design of the page. I threw what is currently working together very quickly because I wanted to get to the jQuery, and it shows. It's all of 2 colors, ugly borders ... very unfinished. Which is okay, because it IS unfinished, and tomorrow I'll try to finish the visual aspects.
After that, I'll add in the jQuery for switching row organizations by column headers, which will involve writing out the entire table 5 times, organized each possible way, and then hiding and showing depending on what the currently selected column is. Finally, I'll work on the PHP to make it truely dynamic, with data pulled from a database.
I've got that done, and there are 3 different columns in the table that correspond to search options. The tricky part was when clicking a box to unhide a category, getting it to only hide people in that category who were also unhidden with the other 2 categories. It's working now, but the code is sort of clunky, so tomorrow I'll try and figure out a way to cut it down.
Also tomorrow I'll work on the CSS and design of the page. I threw what is currently working together very quickly because I wanted to get to the jQuery, and it shows. It's all of 2 colors, ugly borders ... very unfinished. Which is okay, because it IS unfinished, and tomorrow I'll try to finish the visual aspects.
After that, I'll add in the jQuery for switching row organizations by column headers, which will involve writing out the entire table 5 times, organized each possible way, and then hiding and showing depending on what the currently selected column is. Finally, I'll work on the PHP to make it truely dynamic, with data pulled from a database.
Subscribe to:
Posts (Atom)
