echo "Input $QUERY_STRING"
 
-a=`echo "$QUERY_STRING" | sed -n 's,_,/,pg'`
+a=`echo "$QUERY_STRING" | sed -n "s/=on*//pg" | sed -n 's,_,/,pg'`
 
 # escape & if present
 echo "$a" | grep "&" >> /dev/null
 fi
 
 echo "Mods $a"
-#sed -i "s_s,1,Dial(.*) ;; mini-asterisk_s,1,Dial($a) ;; mini-asterisk_" /etc/asterisk/extensions.conf
 sed -i "s_s,1,Dial(.*) ;; mini-asterisk_s,1,Dial($a) ;; mini-asterisk_" /etc/asterisk/extensions.conf
+#sed -i "s_s,1,Dial(.*) ;; mini-asterisk_s,1,Dial($a) ;; mini-asterisk_" /etc/asterisk/extensions.conf
 
 #reload extensions.conf
 
 
       initialisePage();
 }
 
+function GenericReturn(doc,status) {
+    loadHtmlTextFile(doc, function(line) {
+           //parseSipShowPeers(line);
+       }
+       );
+
+      initialisePage();
+}
+
 function OnUpgradeReturn(doc,status) {
     loadHtmlTextFile(doc, function(line) {
            //parseSipShowPeers(line);
 
 }
 
+/**
+ * This functions wraps XMLHttpRequest open/send function.
+ * It lets you specify a URL and will call the callback if
+ * it gets a status code of 200.
+ * @param {String} url The URL to retrieve
+ * @param {Function} callback The function to call once retrieved.
+ */
+function downloadUrl2(url, callback) {
+    var status = -1;
+    var request = createXmlHttpRequest();
+    if (!request) {
+       return false;
+    }
+
+/*    request.onreadystatechange = function() {
+       if (request.readyState == 4) {
+           try {
+               status = request.status;
+           } catch (e) {
+               // Usually indicates request timed out in FF.
+           }
+           if (status == 200) {
+               callback(request.responseText, request.status);
+               request.onreadystatechange = function() {};
+           }
+       }
+    }
+ */
+
+   request.open('GET', url, true);
+    try {
+       request.send(null);
+    } catch (e) {
+       changeStatus(e);
+    }
+
+}
+
+
 
 
   <tr>
     <td><div id="menu"></div></td>
     <td><div id="phones_table"></div></td>
+    <td><input type="button" style="width:100%" value="update reception" onClick="onClickUpdateReception()"></td>
   </tr>
-
   </table>
 </body>
 </html>
 
 
             html += "</td>";
        
-           html += "<td>(Reception)</td>";
+//         html += "<td>(Reception)</td>";
             html += "<td>" + '<img src="tick.png" />' + "</td>";
             html += "</tr>";
        }
     }
 
     // print out submit button
-
+       //doesn't work ... Only use static html buttons
 
     html += "<tr>";
     html += "<td>";
     html += "<a href=ipphones.html    /a>Add IP Phone";
     html += "</td>";
-    html += "<td>";
-    html += "<input type='submit' value='Update Reception' onClick='onClickApply(event)'/>";
+/*    html += "<td>";
+    html += "<input type='submit' value='Update Reception' onClick='onUpdateReception()'/>";
     html += "</td>";
+*/
     html += "</tr>";
 
 
 
     downloadUrl("/cgi-bin/ifconfig.cgi?arg=eth0", processIfconfig);
 //    downloadUrl("/cgi-bin/ifconfig.cgi?arg=eth1", processIfconfig);
+
+       // downloadUrl works fine here.
+//    downloadUrl("/cgi-bin/setring.cgi?Zap_3=on", null);
+
 }
 
 
     document.getElementById('ipaddress').innerHTML = ip;
 }
 
-function onClickApply(e) {
+function onClickUpdateReception() {
 
        // get the arguments from the form  selected[]
        ///document.myform.elements['fav[]'].checked
-       var arg ='';
+       var arg ="";
 
 
        //      number of check boxes in the form
                                arg = arg+"&";
 
                        // got to make up new codes
-                       arg = arg + recept_code[i];
+                       arg = arg + recept_code[i] + "=on";
                }
 
        }
+        var arg2 =  "/cgi-bin/setring.cgi?" + arg;
+       downloadUrl(arg2,null);
+
 
-       downloadUrl("/cgi-bin/setring.cgi?"+arg,null);
+/*     
 
+       // ok looks like static buttons work but my dynamic button line 112 doesnt.
+
+    var ret = downloadUrl("/cgi-bin/setring.cgi?Zap_3=on", GenericReturn);
+    if (ret == false) {
+       throw new Error("XMLHttpRequest not supported");
+       }
+*/
 }
+
+
+
+