Lately I've been working on learning not only JQuery but also more on CSS, Javascript and more PHP. We're using API's to handle any sql calls.Â
An experimental project involved transfer courses and which schools offer which courses that have PSU equivalents was used to not only familiarize myself with jquery but also understand all the other components that are needed (or just desired) to have in the application.Â
Then I moved onto a program which allows a user (via an oracle directory object) to be able to upload their feeds without connecting to unix. JQuery handled this beautifully sans some obstacles such as quotes begin uploaded getting in the way etc. I would like to share bits of this technique.Â
Things that need to happen are:
- Make sure all is secure, I use Yale CAS so the user not only needs a portal account, but they also need to be included in the authorization listing.Â
- Set up the mechanism to get the file to be uploaded.Â
- Give the filename a title which is passed as a parameter
- Allow the user to view the contents before uploading. From the time the file is picked up, it is encoded.Â
- Then when the user clicks on the upload button, it automatically goes to the directory for pickup later on.Â
I can not show all the code, but can show the obstacles that got in my way while working on this. First issue was passing an array successfully. We ended up flattening it out like this:
  <!-- BEGIN: items -->
   <input type="hidden" name="itemarray{items.nbr}" class="itemarray" value="{items.record}" />
  <!-- END: items -->
Then this value is picked up by my behavior.js file containing javascript and jquery where the next php app picks up these values and moves the data along   [segment from behavior.js]:
 $('.itemarray').each(function(){
  var statement='variable_list.'+$(this).attr('name')+'="'+$(this).val()+'"';
  eval(statement);
 })
What that basically did was, after I assigned a class called itemarray (in the template), jquery can now search for the class and pick up the attributes and values. If you want to put it back into an array afterwards, just assign the values in a loop back into it.Â
Issue #2: This one had me stumped at first, but although it picked up the file I was transferring correctly, when I tried to upload a comma quote delimited file - the items in behavior.js didn't know what to do with the quotes! Finally I found that if you do a urlencode first when sending the values and then urldecode the values when you wish to view the results, it works great. If you do nothing and there are quotes in the file, nothing will upload and the process will fail.Â
So, the process is now working. Thanks to Matt Batchelder for helping me with some of this and getting me started with jquery! Hope you find some of this useful.Â