I would like to run a function when a user checks a checkbox to update a fields in a database. I know to call a function using 'onCLick' you have to write a function through script, however I am unsure how to or if you can then run a query in Javascript.
Will I need to use VBScript instead?
Any help (or a quick example) would be greatly appreciated.
Thanks.
*edit: sorry, i meant to post this in the database section.
mySQL query using script
Moderator: General Moderators
-
kristolklp
- Forum Commoner
- Posts: 30
- Joined: Mon Sep 05, 2005 2:24 pm
oic...thanks for the quick reply.
How do i submit a form using onClick? This is how I was calling my function.
Is it as simple as doing:
How do i submit a form using onClick? This is how I was calling my function.
Code: Select all
<input type="checkbox" name="update" onClick="UpdateSetting();">Is it as simple as doing:
Code: Select all
<input type="checkbox" name="update" onClick="document.formName.submit();">- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
No, I think Feyd is trying to tell you that the server needs to handle the processing not the client machine. That means that the onClick event will not generate the results you want because a client side script cannot interact with a database.
Process the form as normal and handle the database interaction with the server-side script.
Process the form as normal and handle the database interaction with the server-side script.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Just to clarify, there are two parts to your question. One that involves the submission of a form based on a clicke vent raised when a checkbox is checked (this is a client-side code question - Javascript). The other is what happens after the form is submitted (a server-side code question - PHP). I do not want to step on Feyd's toes with my previous answer.kristolklp wrote:gotcha. thanks!
The form submission can be handled in a number of ways, even using a text link to post back to the script. The actual processing of the data that was sent by the form being submitted is what needs to be handled on the server.