How to upgrade select option code

How to upgrade select option code

I have some jquery code that is quite old that uses "removeOption(/./).addOption(cats_reg, false)" to change the select options based on a checkbox. The version of jquery is jquery-1.3.2.js.  

I have to move my code to where jquery 1.10.2 is being used. The code removeOption(/./).addOption(cats_reg, false) is no longer functions in the new jquery. 

  1. $("#offcampus_ws_box").click(function(){
  2. $(".offcampws").toggle();
  3. $(".chngtxt").toggle();
  4. if (cats_reg !== undefined) {
  5. if (!($("[name=jobs_workstudy]").attr("checked"))) {
  6. $("[name=jobs_categories_name]").removeOption(/./).addOption(cats_reg, false);
  7. if (!wasWorkstudy){
  8. document.form.jobs_categories_name.selectedIndex=selected;
  9. }
  10. } else {
  11. $("[name=jobs_categories_name]").removeOption(/./).addOption(cats_ws, false);
  12. $("#benefits_text").html("<strong>Educational Benefits:</strong>");
  13. if (wasWorkstudy){
  14. document.form.jobs_categories_name.selectedIndex=selected;
  15. }
  16. }
  17. }
  18. });

If it helps, cats_reg and cats_ws select option items are created as follows in php:

  1. $cats_reg = "SELECT categories_name FROM ...";
  2. $r = pg_query($conn, $cats_reg) or die(pg_last_error());
  3. echo "var cats_reg = {\n";

  4. $num = pg_num_rows($r);
  5. for ($i=0; $i<$num; $i++) {
  6. $d = pg_fetch_row($r,$i);

  7. echo "\"$d[0]\"" . " : " . "\"$d[0]\"";
  8. if ($i<($num-1)){
  9. echo",\n";
  10. }else{
  11. echo"\n";
  12. }
  13. }
  14. echo "};\n";


  15. $cats_ws = "SELECT categories_name FROM ...";
  16. $r = pg_query($conn, $cats_ws) or die(pg_last_error());
  17. echo "var cats_ws = {\n";
  18. $num = pg_num_rows($r);
  19. for ($i=0; $i<$num; $i++) {
  20. $d = pg_fetch_row($r,$i);

  21. echo "\"$d[0]\"" . " : " . "\"$d[0]\"";
  22. if ($i<($num-1)){
  23. echo",\n";
  24. }else{
  25. echo"\n";
  26. }
  27. }
  28. echo "};\n";
  29. }

What is the equivalent or how do I upgrade the code to have it work in the new jquery?

Thanks