Click to See Complete Forum and Search --> : Pass javascirpt variable to asp


zw1971
10-19-2003, 08:06 AM
How?

I have a javascript function like this:

<script language="JavaScript">
function processLists(list){
var selectedItems = getSelectedValues(list)
alert("You have selected = "+selectedItems+" items from list")
}


function getSelectedValues(list){
var len = list.length;
var ctr=0;
var values = new Array();
for(x=0;x<len;x++){
if(list[x].selected ){
values[ctr] = list[x].value;
ctr++;
}
}
return values;
}
</script>

How can I pass the variable selectedItems to the asp code on the same page when the form is submitted?

rdoekes
10-19-2003, 09:35 AM
You can only do that if you pass the variable to the form when you submit.

So you make a hidden input in your form, and you make a function which gets triggered onSubmit:
<form onSubmit="ProcessSelectItems(this)">.......etc.....
<input type="hidden" name="selectItems" value="0" />
</form>

This function assigns the selectItems variable to the input field:


function ProcessSelectItems(oForm) {
oForm.selectItems.value = selectItems;
return true;
}

the selectItems form element will now be accessible in the Request.Form collection in ASP

-Rogier Doekes

zw1971
10-19-2003, 05:56 PM
Thanks buddy, That's what I did. And it works.

I have another problem: how to set permission of Access database on remote server?

pelegk1
10-20-2003, 02:19 AM
javascript function
after u got the value to do
window.location.href="yourpage.asp?selectedVal="+val;

rdoekes
10-20-2003, 03:04 AM
Pelegk1,

Your proposed solution does not submit the form. Therefore, if you have more form elements which you would like to expose and handle in the asp page, this solution will only expose the selectItems and not via Request.Form but Request.QueryString.

zw1971,

Coming back to your question of permission. I believe the permissions on a specific file cannot be set via FTP. You have to have terminal access, whether it be an administrator manually setting the permissions, or you logging into the remote server using Terminal Services or PCAnywhere.

-Rogier Doekes

piersk
10-21-2003, 11:36 AM
Often web hosts will leave a directory that has write access to it, eg. Brinkster says to put your db in the db folder.