[HOW TO] How to add ONCHANGE to forms
Posted: Mon Nov 29, 2010 7:11 am
I found this simple JavaScript to change a form to when you select form the dropdown box. Once this is working, it shoudl allow you to select anything form the dropdown box on the Order page and it will automatically go to that page instead of clicking the Filter button.
I did try to add it, but I think I keep missing something! So below is the example I found. I was trying to add it to the admin/view/template/saleorder_list.tpl on the form found around line 17.
Maybe one of our finder minds on here can whip this!
Here's what I did so far. I added this before the <form tag on line 17.
Then I added name="form1" to
making it
And finally I added ONCHANGE="goto(this.form)" to
so it reads as
Since the example shows that the <select name="" should be "select", I used the existing name, name="filter_order_status" that was already there and changed every instance of it in the SCRIPT above. I replaced form.select. with form.filter_order_status. All that did was read the number selected for that particular selection. I take it since it is already being used by more of the select function below where you find it, that it has something to do with only displaying the number of that selection. I'm sure it's something simple I am missing! lol SO that is where I am stuck! haha...anyone have a tow rope?
Thanks,
Gilmore
I did try to add it, but I think I keep missing something! So below is the example I found. I was trying to add it to the admin/view/template/saleorder_list.tpl on the form found around line 17.
Maybe one of our finder minds on here can whip this!
Code: Select all
<Script language="JavaScript">
<!--
function goto(form) { var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}
//-->
</SCRIPT>
<FORM NAME="form1">
<SELECT NAME="select" ONCHANGE="goto(this.form)" SIZE="1">
<OPTION VALUE="">-------Choose a Selection-------
<OPTION VALUE="index.htm">Home
<OPTION VALUE="web_development.htm">Web Development
<OPTION VALUE="html_codes.htm">HTML Tips
<OPTION VALUE="html_codes_chart.htm">HTML Code Chart
<OPTION VALUE="javascript_codes.htm">JavaScript Codes
<OPTION VALUE="216_color_chart.htm">Color Code Chart</SELECT>
</FORM>
Code: Select all
<!-- Start Form MOD ONCHANGE -->
<Script language="JavaScript">
<!--
function goto(form) {
var index=form.select.selectedIndex
if (form.select.options[index].value != "0") {
location=form.select.options[index].value;}}
//-->
</SCRIPT>
<!-- End Form MOD ONCHANGE -->
Code: Select all
<form action="" method="post" enctype="multipart/form-data" id="form">
Code: Select all
<form action="" method="post" enctype="multipart/form-data" id="form" name="form1">
Code: Select all
<select name="filter_order_status_id">
Code: Select all
<select name="filter_order_status_id" ONCHANGE="goto(this.form)">
Thanks,
Gilmore