Snippets/Post2 Get String
Post2GetString ¶<script language="javascript"> function post2get(form){ var allowType = "checkbox, hidden, password, radio, text"; var formstring = ""; formstring += form.action; formstring += "?"; for(i=0 ; i<form.elements.length ; i++){ var elementType = form.elements[i].type; if(allowType.indexOf(elementType) != -1){ switch (elementType){ case "checkbox": break; case "hidden": formstring += form.elements[i].name+"="; formstring += form.elements[i].value+"&"; break; case "password": formstring += form.elements[i].name+"="; formstring += form.elements[i].value+"&"; break; case "radio": formstring += form.elements[i].name+"="; formstring += getRadioButtonValue(form.elements[i])+"&"; break; case "select": formstring += form.elements[i].name+"="; formstring += getSelectedOptionValue(form.elements[i])+"&"; break; case "text": break; default: } } } return formstring; } function getSelectedOptionValue(obj) { if ( obj.selectedIndex != -1) { var idx = obj.selectedIndex; var v_sel = obj.options[idx].value; } else var v_sel = ""; return v_sel; } function getRadioButtonValue (radio) { if(radio.length == null) return radio.value; for (var i = 0; i < radio.length; i++) { if (radio[i].checked) { break; } } return radio[i].value; } </script> |
By failing to prepare, you are preparing to fail. |