[Javascript] submit form functions

Grinwald, Uri UGrinwald at dynamic.ca
Thu Oct 14 14:38:01 CDT 2004


That was exactly was I was trying to do.
Thanks for your help with all this.
Very Nice Coding
Uri :)

-----Original Message-----
From: Allard Schripsema [mailto:allard-schripsema at procergs.rs.gov.br] 
Sent: Thursday, October 14, 2004 3:24 PM
To: [JavaScript List]
Subject: RE: [Javascript] submit form functions


Uri,
This code will post the value of the select
using the field hdqryCategory.
The replace is to clean up the spaces in the value.
I tested it with
<%response.write request.form("hdqryCategory")%>

Allard

<html><head></head>
<script>
function getFilter(listitem){

document.formCategory.hdqryCategory.value=document.formCategory.qryCateg
ory.
value.replace(/ /g,"")
	document.formCategory.submit();
}
</script>
<body>
<FORM name="formCategory" action="manageproduct.asp" method=post>
<SELECT NAME="qryCategory" method=post onChange="getFilter(this)"
size="1" class="loginmenu"> <option selected>Select a category</option>
<option value=8 >Bracelets</option> <option value="7
7">Earrings</option> <option value=16 >Hair Supplies</option> <option
value=9 >Necklaces</option> <option value=10 >Rings</option> </select>
<input id="hdqryCategory" name="hdqryCategory" value="hdqryCategory"
type=hidden value=""> </FORM> </body> </html>

-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu]On Behalf Of Grinwald, Uri
Sent: Thursday, October 14, 2004 3:02 PM
To: [JavaScript List]
Subject: RE: [Javascript] submit form functions


Sorry Allard,

Here is the actual code.
I only added the remove space function because I wanted to retain a
space in one of my drop downs that reads " Hair Supplies" with the same
Value "Hair Supplies". Unfortunately because of the space it only
returns as "Hair" which does not match any values in my database. This
is my problem.


Here are the two functions along with the HTML code for the submit
button. If I can return the value of the select box in a hidden field
then I can keep my space. I know that a variable in a querystring cannot
contain any spaces so I think that is why it is just dropping the
"Supplies" portion


function getFilter(listitem){
	var object = "";
	var listValue = getListValue(listitem);
	document.formCategory.submit(listValue);
	//alert(listValue);

}


function getListValue(list){
	var listValue="";
	if (list.selectedIndex != -1) {
		listValue = list.options[list.selectedIndex].value;
		listValue = removeSpaces(listValue);
		}
	return (listValue);
}


AND HTML FOR FORM (Being populated by database)

<FORM name="formCategory" action="manageproduct.asp">

<SELECT NAME="qryCategory" onChange="getFilter(this.form.qryCategory)"
size="1" class="loginmenu">
<option selected>Select a category</option>
<option value=8 >Bracelets</option><option value=7
>Earrings</option><option value=16 >Hair Supplies</option><option
value=9 >Necklaces</option><option value=10 >Rings</option> </select>


</FORM>

-----Original Message-----
From: Allard Schripsema [mailto:allard-schripsema at procergs.rs.gov.br]
Sent: Thursday, October 14, 2004 1:21 PM
To: [JavaScript List]
Subject: RE: [Javascript] submit form functions


Hi Uri,

1st suggestion: set the form method to post instead of get...

If you already have that, show us the code for the submit..... , Some
questions:
Are you using the getListValue(list) in the submit code???
Why is the select not inside the form you?re submitting?

A comment:
Why do a removespaces in javascript if you can treat that serverside?
(observation: the tstring variable when you return string?)
if you want to clean spaces why not use a regular expression : / /g

Allard


-----Original Message-----
From: javascript-bounces at LaTech.edu
[mailto:javascript-bounces at LaTech.edu]On Behalf Of Grinwald, Uri
Sent: Thursday, October 14, 2004 11:38 AM
To: [JavaScript List]
Subject: RE: [Javascript] submit form functions


Hi Guys.

I currently have a drop down list being populated by values from an
access database. When the user selects an option two javascript
functions are used on the onChange event handler. One that retrievs the
value and the other that submits the form.

function getListValue(list){
	var listValue="";
	if (list.selectedIndex != -1) {
		listValue = list.options[list.selectedIndex].value;
		listValue = removeSpaces(listValue);
		}
	return (listValue);
}
function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return string;
}

My problem is that the value is being passed as a URL variable which
means I am using the QueryString to obtain the value. This is being
displayed in the URL address bar so I tried changing the form to post
but that causes the functions to not work altogether. Is there a way of
maybe having the function pass the value as a hiidne field so that I can
use the Request.Form to obtain the value?

Thanks for your time.

Uri
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript



More information about the Javascript mailing list