Wednesday, November 3, 2010

Jquery trigger() all checkboxes

ok, so I'm a complete newb when it comes to Jquery but I'm learning... I know that it's the fucking tits for any type of Web development. I had a situation where I wrote a simple form with checkboxes, when the user clicked on a checkbox it would trigger an OnChange() event and call an AJAX script to do some DB work. That form I just mentioned works like a champ, however, the customer now wants a selectAll/Deselect Checkbox for a given "class" which could be 10 or 15 checkboxes per "class".

Anyway, I knew the solution was to use the kick ass power of Jquery I just didn't know how the hell to accomplish this task. The solution was to use ideas from this kick ass Jquery plugin:

http://www.itsalif.info/content/ezmark-jquery-checkbox-radiobutton-plugin


My working solution below... The magic is in Jquery's trigger() function which will pragmatically simulate a human event.





<form action="#" method="post" id="myform">

<fieldset>
<input name="checkall" id="checkall" type="checkbox">

<input name="checkbox1" onchange="DO SOMETHING...." id="checkbox1" type="checkbox">
<input name="checkbox2" id="checkbox2" type="checkbox">
<input name="checkbox3" id="checkbox3" type="checkbox">
<input name="checkbox4" id="checkbox4" type="checkbox">
<input name="checkbox5" id="checkbox5" type="checkbox">
<input name="checkbox6" id="checkbox6" type="checkbox">
<input name="checkbox7" id="checkbox7" type="checkbox">
<input name="checkbox8" id="checkbox8" type="checkbox">
<input name="checkbox9" id="checkbox9" type="checkbox">
<input name="checkbox10" id="checkbox10" type="checkbox">
</fieldset>

</form>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>


<script type="text/javascript"><br />$(function () {<br /> $('#checkall').click(function () {<br /> $(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked', this.checked).trigger('change');<br /> <br /> });<br />});<br /></script>

Monday, August 30, 2010

Microsoft Access porting rant

I'm converting an Access db to MS SQL Server for work which is an absolute pain in itself.... SSMA you say ? That amazing product breaks down when it encounters anything mildly complex like porting an Access TRANSFORM PIVOT to TSQL. The tool chokes and says "Crosstab query is not supported". No shit.... but since SQL Server 2005 we've had the PIVOT predicate. Would it honestly be too difficult to program a routine/method into the SSMA wizard to handle TRANSFORM to TSQL PIVOT situations ?

The above rant is not even why I posted today. The icing on the cake is a little predicate in Access called an "iif" statement, and no I didn't spell that wrong. Aparently, some dill hole thought it would be a good idea to have the mentioned "iff" statement instead of banging out the traditional IF ElSE that is in every single language since the dawn of computing. Yes, you can do a traditional IF....ELSE in Access but you can also do the "iif". The reason why we have IEEE, RFCs, and other standardizing methods and organizations is so shit like this doesn't happen, but then again Microsoft has always done their own thing...

Friday, August 13, 2010

comparing tables on SQL Server 2005/2008

I've been using a god awful UNION ALL script and you can now compare using the EXCEPT statement:

select * from table1
except
select * from table2



short and sweet !

Monday, June 14, 2010

DTS Dynamic Properties

You can use:
 DTSGlobalVariables("SERVER_NAME").Value

in your ActiveX scripts to reference global variables in the package. SERVER_NAME is a variable name you create.


You can also setup a "Dynamic Properties Task" within a package to manage connections for a package.

The kicker is how do you use a dynamic property concatenated with a static string in, for example,
the file name box
in the connection properties for a source text file connection ?