Jump to content

getting info from client to server


eastn

Recommended Posts

I am using what I assume to be pretty straightforward asp, xhtml and scripts (vbscript, javascript) to manage my website. Everything is working OK, including maintaining an MS Access db on the server from form data, and reading and updating folders & files on the server.But I have one more need:The only way I have found, of passing any info back from the client to the server is by using a form - the form displays on the client, the user enters data and submits the form, and the data can then be picked up in ASP, ie, on the server. I can then, for example, write the form data to my MS Access db on the server, and pass it back to the client in whatever form I need it in the html.But I want to be able to pass back (small amounts of) data without using a form. For example, if the user clicks on a certain field (like a cell in a table), I want to resubmit the .asp file (as I would for form data) so that in my asp code I can pick up the fact that the user has clicked field "x" and act accordingly (eg. update a db record and redisplay).I can't find any way of doing this. Some things, like the Session object, appears to be accessible only on the server. Other things, like window.location.search, appear to be accessible only on the client. Such a mechanism must logically exist, because it exists for form data.XMLHttpRequest appears to pass data back to the server, but it is far too complicated for my liking.Any ideas?TIA

Link to comment
Share on other sites

I am using what I assume to be pretty straightforward asp, xhtml and scripts (vbscript, javascript) to manage my website. Everything is working OK, including maintaining an MS Access db on the server from form data, and reading and updating folders & files on the server.But I have one more need:The only way I have found, of passing any info back from the client to the server is by using a form - the form displays on the client, the user enters data and submits the form, and the data can then be picked up in ASP, ie, on the server. I can then, for example, write the form data to my MS Access db on the server, and pass it back to the client in whatever form I need it in the html.But I want to be able to pass back (small amounts of) data without using a form. For example, if the user clicks on a certain field (like a cell in a table), I want to resubmit the .asp file (as I would for form data) so that in my asp code I can pick up the fact that the user has clicked field "x" and act accordingly (eg. update a db record and redisplay).I can't find any way of doing this. Some things, like the Session object, appears to be accessible only on the server. Other things, like window.location.search, appear to be accessible only on the client. Such a mechanism must logically exist, because it exists for form data.XMLHttpRequest appears to pass data back to the server, but it is far too complicated for my liking.Any ideas?TIA

Link to comment
Share on other sites

I am using what I assume to be pretty straightforward asp, xhtml and scripts (vbscript, javascript) to manage my website. Everything is working OK, including maintaining an MS Access db on the server from form data, and reading and updating folders & files on the server.But I have one more need:The only way I have found, of passing any info back from the client to the server is by using a form - the form displays on the client, the user enters data and submits the form, and the data can then be picked up in ASP, ie, on the server. I can then, for example, write the form data to my MS Access db on the server, and pass it back to the client in whatever form I need it in the html.But I want to be able to pass back (small amounts of) data without using a form. For example, if the user clicks on a certain field (like a cell in a table), I want to resubmit the .asp file (as I would for form data) so that in my asp code I can pick up the fact that the user has clicked field "x" and act accordingly (eg. update a db record and redisplay).I can't find any way of doing this. Some things, like the Session object, appears to be accessible only on the server. Other things, like window.location.search, appear to be accessible only on the client. Such a mechanism must logically exist, because it exists for form data.XMLHttpRequest appears to pass data back to the server, but it is far too complicated for my liking.Any ideas?TIA

I think using XMLHttpRequest overcomplicates everything, you don't need AJAX for something this simple.The easiest way to do this is putting querystring data in the link you want you're users to click. An example might look like this:Clickrows.asp
<table><%Dim IFor I = 1 to 10%>    <tr>        <td><a href="update.asp?row=<%=I%>">Row <%=I%></a>    </tr><%Next%></table>

When a user clicks a link above, they will be forwarded to the URL a page called update.asp, and they'll be sending the querystring "row=1". This works exactly the same as using a form (with method="get") to send the data. Now you can write your update.asp page to change the necessary values in your database:Update.asp

<%Dim myRowmyRow = request("row")' Open a connection' Update your table' Close connectionresponse.redirect "clickrows.asp"%>

If you're users don't like the page refreshing everytime they click a link, you can try using AJAX. I recommend this page as an example for updating databases.Edit to add:Oh, looks like I was too slow to type this, glad you got your problem fixed.But I also want to add, you don't really need to use Request.Form or Request.QueryString. If you use Request("your_var"), then you can get the value passed by Your_Var regardless of whether it was passed by method=post or method=get.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...