473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Counting Click Throughs

Does anyone know of a quick method of inserting records into a text file or
database using OnClick?
Jul 20 '05 #1
2 1489
There is no short cut - you will have to make a request to the server.
"Smoke" <sm***@xatrium.com> wrote in message
news:zCtpb.137088$sp2.55609@lakeread04...
Does anyone know of a quick method of inserting records into a text file or database using OnClick?

Jul 20 '05 #2
steve stevo wrote:
There is no short cut - you will have to make a request to the server.

"Smoke" <sm***@xatrium.com> wrote in message
news:zCtpb.137088$sp2.55609@lakeread04...
Does anyone know of a quick method of inserting records into a text file

or
database using OnClick?


Assuming the database or text file he wants to insert data into is on the
server, he has to make a request to the server. However, he can use a variety
of "shortcuts" which do not involve using POST or GET with a form. Here is a
simple example:

<form name="myForm">
<input type="text" name="theValue" />
<input type="button" value="Insert" onclick="insertValue(this.form);" />
</form>
<script type="text/javascript">
function insertValue(f) {
var cgiCaller = new Image();
cgiCaller.src = 'somethingThatInsertsTheValue.cgi?theValue=' +
f.theValue.value;
}
</script>

Of course there are obvious disadvantages to doing this. Client-side
JavaScript has to be enabled, you can't retrieve any sort of information about
whether the insert was successful or not, etc. I don't recommend doing this
unless you really don't care if the server did what you just asked it to do,
but it is an option if that's your requirement.

The advantages are that you do not need to reload the user's browser, even to
reload the form, so the user can probably send data to the server as fast as
they can change the value in the input and click the button.

The same sort of "shortcut" can be done using the HTTP Request object <url:
http://jibbering.com/2002/4/httprequest.html />. However, because of the added
complexity of implementing it, I usually find it easier to POST a form when I
need to get information back from the server about the state of the
transaction I just asked it to perform. The additional benefit of a POST or
GET is that it will still work even if the user has disabled client-side
JavaScript.

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Shanfeng Cheng | last post by:
I write a piece of code to tracking the number of clicks on a link each day. The link usu. gets about 3000-6000 clicks per day. I just store today's click count in a one-line text file, like, ...
1
by: Britney | last post by:
hi, I have user picture on aspx main page, if end-user click it 100 times, then number_of_clicks will increment to 100. however, What we do right now is that everytimes a user click on the...
11
by: Al | last post by:
Can anyone tell me if there's a way to return the amount of times a button is "clicked" I need to change text in a text box and that text changes each time the button is clicked-up to 6 times...
1
by: Jerry | last post by:
We have a 10-question quiz for kids, each question being a yes or no answer using radio selections. I'd like to keep a current total of yes's and no's at the bottom of the quiz (if the user selects...
4
by: aaronfude | last post by:
Hi, Please consider the following class (it's not really my class, but it's a good example for my question): class Vector { int myN; double *myX; Vector(int n) : myN(n), myX(new double) { }...
1
by: powerej | last post by:
I have gotten the part of counting how many words are in the string, but the vowels just seem alien to me. Ive tried so many things but never close to a correct answer. I know I need to use...
1
by: jeganrd | last post by:
i have problem using distinct query. I have table it has 22 fields. call_id is repeted because of maintain the history. when i insert the same record as another record some filelds should...
17
by: Razii | last post by:
This is specifically regarding U++ which is C++ libraries and IDE (please don't whine whether its on or off topic. Right click on the thread and click on ignore instead of wasting time). This is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.