I am developing a website with perl cgi, HTML, JavaScript and sas SQL.
In html page, there are few drop down list, different item of witch, will call specific cgi file to create new webpage. Those are all working very good.
Now, I added search function, with witch the value entered to text box has to be send, when clicking submit button. The URL of cgi was on the form action.
But something happens. It did not go to the URL of action, but go to the URL of previous one the on-change event did.
my question without search form, change forms worked fine.
After creating search form by entering value into text box and submitting the form, it did not call search.cgi. If on change event happened before, it will go to the same URL.
But something happens. It did not go to the URL of action, but go to the URL of previous one the on-change event did.
Impossible. Forms act always independently. My thought is that your HTML code is not well formatted. Do you have a Doctype? Which one?
Try, when coding in HTML, to follow this simple rules:
- always close the tags. If the Doctype is XHTML and the tag is an "empty" one, close it in XHTML style.
- don't interleave the tags. That means avoid something like:
<tag1>
<tag2>
</tag1>
</tag2>
- use lowercase for tags, attributes and events
- use double quotes for attributes' values
There is a better way to reference the selected option of the select control (drop down list). Use (this.value) instead of (this.options[selected].index). Also you should use (location.href) instead of just (location).
len = document.search.schby.length;
i = 0;
chosen = "none";
for (i = 0; i < len; i++) {
if (document.search.schby[i].selected) {
chosen = document.search.schby[i].value;
document.search.schby[i].options.selected = true;
}
return chosen;
}
</script>
with this, I would like to create a search function:
1. search by id or name, the textbox will be displayed. then submit to go to cgi on action url.
2. search by management-type or owner, the dropdown list will be diaplayed, then select to go to cgi by url.
At very beginning, if I search ID or Name, submit worked fine.
After dropdown list was selected, onchage worked fine also. Then, if search by ID or Name again, it won't work.
Hopefully, i explaned my question much clearly....
Bookmarks