minor bug on package-stats.php (and bugfix!)

From: Date: Sun, 31 Aug 2003 14:46:25 +0000
Subject: minor bug on package-stats.php (and bugfix!)
Groups: php.pear.webmaster 
Request: Send a blank email to pear-webmaster+get-492@lists.php.net to get a copy of this message
Hello, I just found this bug in package-stats.php in older browsers (e.g. Netscape 4.x). Go to any package statistics page, e.g. http://pear.php.net/package-stats.php?pid=87&rid=&cid=23 then, choose any other package in the second pulldown menu (where currently SOAP is selected). you get redirected to http://pear.php.net/package-stats.php?cid=null&pid=null&rid=null which leads to a warning message (probably due to the "null"s in the URL). The error lies in the JavaScript method reloadMe() that is executed when a package is chosen in the pulldown: function reloadMe() { var newLocation = '/package-stats.php?' + 'cid=' + document.forms[1].cid.value + '&pid=' + document.forms[1].pid.value + '&rid=' + document.forms[1].rid.value; document.location.href = newLocation; } Resolution: The shortcut "FORMELEMENT.value" to retrieve the value of the currently selected entry in a pulldown menu is not supported by all browsers. This should work with all browsers: function reloadMe() { var newLocation = '/package-stats.php?' + 'cid=' + document.forms[1].cid.options[document.forms[1].cid.selectedIndex].value + '&pid=' + document.forms[1].pid.options[document.forms[1].pid.selectedIndex].value + '&rid=' + document.forms[1].rid.options[document.forms[1].rid.selectedIndex].value; document.location.href = newLocation; } Note: reloadMe() is executed when any of the pulldown values is changed; using the middle pulldown is just for demonstration. Also, package-stats.php contains three occurrences of onchange="javascript:reloadMe();" This should be changed to onchange="reloadMe();" (after an event handler, JavaScript code is mandatory, so the "javascript:" pseude protocol is unnecessary). If you have additional questions, please email me directly, I am trying to subscribe to the list digest for two weeks now, yet I am unsuccessful :) Regards Christian

« previous php.pear.webmaster (#492) next »