Gossamer Forum
Home : Products : DBMan : Customization :

Autosave record

Quote Reply
Autosave record
Let me see if i can explain this right.Crazy

I have DBman set up as a log book. After people log in and create a new log, input the info and they leave it at the edit page for hours! How do I or can I make it save and show the add_success sub automaticlly. you know like after you hit the Submit button. I am using the short/long mod.

My last question was about file uploading and then displaying it...that got put on the back burnerUnsure, but I will work on it.

this forum is the best I've been on! so many great question/ideas and so many great/knowledgeable answers!


Quote Reply
Re: [amfreak] Autosave record In reply to
Hello amfreak,

Well let me see.

I believe that you could setup an applet or javascript that could auto submit after a certain amount of time.

I'll play around with it and see what I can do.

The logon expiration time, which is probably what you were hopping to use, requires access to the cgi either from a link or button so it won't work for your needs.


beetlemanTongue

Marcus L. Griswold
Quote Reply
Re: [beetleman] Autosave record In reply to
Okay, lets give it a try!

In the body tag of the html template for the page you want to limit add:
Code:
onLoad=window.setTimeout("location.href='javascript:document.form1.submit()'",10000)
where form1 is the name of the form used (form1 by default in dbman)
10000 = 10 seconds

In the same html template change:
Code:
<INPUT TYPE="SUBMIT" NAME="add_record" VALUE="Add Record">
to read:
Code:
<input type="hidden" name="add_record" value="Add Record">
<input type="submit" value="Add Record">

******** Important ********

Please make sure to back up you html.pl file before starting.
Just in case!Wink



Good Luck


beetlemanTongue

Marcus L. Griswold
Quote Reply
Re: [beetleman] Autosave record In reply to
Does this look right? cause it didnt work. I left the old buttons in, just makred them with ##.
the new buttton works just like the old one. It saves the record when pressed. But no autosave....I think I didnt do something right......would be the first time Blush .bold is what I changed or added.

sub html_add_form {
# --------------------------------------------------------
# The add form page where the user fills out all the details
# on the new record he would like to add. You should use
# &amp;html_record_form to print out the form as it makes
# updating much easier. Feel free to edit &amp;get_defaults
# to change the default values.

$page_title = "Start a New Log";
&amp;html_page_top;

$submit_button = "Save Log";
$reset_button = "Reset Form";

# &lt; -- Start page text -- &gt;
print qq|

|;
# &lt; -- End page text --&gt;

print qq|
&lt;form action="$db_script_url" method="POST" name="form1"&gt;
&lt;input type=hidden name="db" value="$db_setup"&gt;
&lt;input type=hidden name="uid" value="$db_uid"&gt;
|;

&amp;html_record_form (&amp;get_defaults);

print qq|
&lt;p&gt;&lt;center&gt;
&lt;body onLoad=window.setTimeout("location.href='javascript:document.html_add_form.submit()',100)"&gt;
&lt;INPUT TYPE="hidden" NAME="add_record" VALUE="Add Record"&gt;&amp;nbsp;
&lt;INPUT TYPE="submit" VALUE="Add Record"&gt;
## &lt;INPUT TYPE="SUBMIT" NAME="add_record" VALUE="$submit_button"&gt;&amp;nbsp;
## &lt;INPUT TYPE="RESET" VALUE="$reset_button"&gt;
&lt;/center&gt;&lt;/p&gt;&lt;/form&gt;
|;
# remove the options from the bottom of the add a record. this way they can only save the record.
# &amp;html_footer;
&amp;html_page_bottom;
}
Quote Reply
Re: [amfreak] Autosave record In reply to
amfreak,

Multiple format programing isn't very easy is it. Perl, HTML, and now JavaScript; makes it difficult to keep track of what's going on doesn't it?

Okay, I found 1 big problem and 1 small problem.
Wink
Here's the solution:

Quote:
# &lt; -- End page text --&gt;

print qq|
&lt;form action="$db_script_url" method="POST" name="form1"&gt;
&lt;input type=hidden name="db" value="$db_setup"&gt;
&lt;input type=hidden name="uid" value="$db_uid"&gt;
|;

&amp;html_record_form (&amp;get_defaults);

print qq|
&lt;p&gt;&lt;center&gt;
&lt;body onLoad=window.setTimeout("location.href='javascript:document.html_add_form.submit()',100)"&gt;
&lt;INPUT TYPE="hidden" NAME="add_record" VALUE="Add Record"&gt;&amp;nbsp;
&lt;INPUT TYPE="submit" VALUE="Add Record"&gt;


Form Name:
I should have been clearer. The name in the <form> tag is what I meant.
So if your html reads:
&lt;form action="$db_script_url" method="POST" name="form1"&gt;

Then:
onLoad=window.setTimeout("location.href='javascript:document.form1.submit()',100)"&gt;

Time:
100
As set (100) your form will auto submit 0.1 seconds after page load.
The time set is measured in milliseconds so:
1 second = 1000
10 seconds = 10000
100 seconds = 100000
1 hour = 3600000 (1000 milliseconds x 60 seconds x 60 minutes = 3600000)

Please note the timer starts at page load.

By the way, what's up with all of the special characters in the post?
ie. &gt; instead of >.

It makes it particularly difficult to isolate any problems.
I assume whatever program you used to cut and paste the segment with only reads
them encoded.
Notepad may suit your needs better unless you prefer to progam using special character encoding.

Good Luck,

Quote Reply
Re: [beetleman] Autosave record In reply to
amfreak,

Once all of the bugs are out and everything works, you should be able to continue using your $submit_button variable and add the reset button back in.


beetlemanTongue

Marcus L. Griswold
Quote Reply
Re: [beetleman] Autosave record In reply to
Thanks I'll give it a try and tell ya about it.

I put in the 100 just to make it do it fasterBlush.

the &amp;gt isn't in my code must have been from when I pasted it. It is a < or > in the code. I use EditPlus. Its a really nice program.

I'm trying to learn this stuff as I wonder thru it and bang my head againt the desk.Pirate
Quote Reply
Re: [amfreak] Autosave record In reply to
I must be doing some thing wrong or I just dont understandCrazy. filp a coin. hehehe

is there some where i can read about this? dont have to tell it to use a java script?

just need something that acts like it pushes a button i want.
Quote Reply
Re: [amfreak] Autosave record In reply to
amfreak,

I just saw a problem (probably THE problem),

Move the Blue (")
From here:
Code:
onLoad=window.setTimeout("location.href='javascript:document.form1.submit()',100)">

To Here:
Code:
onLoad=window.setTimeout("location.href='javascript:document.form1.submit()'",100)>

Sorry I missed it before.

What browser are you using so I can check compatability. Although this JavaScript is cross compatable, there may still be a bug to work out.
Name and Version (ie. IE 4.0 or Netscape 4.6).

Confussion:
I pieced the JavaScript together from two samples at:
JavaScript Resource

Both scripts are realitivly common scripts.
The first is a refresh script to redirect if a page has moved to a new domain.
The second is a submit link instead of a button.

The Logic:
<body onLoad=.....>
---> execute operation after equal sign when page loads.
window.setTimeout(,)
---> is a predefined JavaScript function - (do this, after this is true)
"location.href=' '"
---> Change location to 'this'
javascript:document.form1.submit()
---> This is a URL in this case it points to this document, the form named
---> "form1", the input field "Submit". Basically, press the submit button in
---> "form1"!
100
---> The argument, when count in milliseconds reaches this number execute
---> "location.href='javascript:document.form1.submit()'"

Hope this helps.

As far as I know, there aren't very many ways to auto-submit and JavaScript is the easiest and most compatable way to do it. In fact it is the only way I know to do it. An SSI might do the same thing but I can't use SSI on my server so I can't test it.

The JavaScript does work, I ran it on my test DB and had no problems.
Not saying its your fault, just reassuring you that you aren't wasting your time.

Good Luck,

beetlemanTongue

Marcus L. Griswold
Quote Reply
Re: [amfreak] Autosave record In reply to
Of course after I posted the last mesage it works Tongue.


Code
<body onLoad=window.setTimeout("location.href='javascript:document.form1.submit()'",10000)
# <INPUT TYPE="SUBMIT" NAME="add_record" VALUE="$submit_button">&amp;nbsp;
# <INPUT TYPE="RESET" VALUE="$reset_button">
<input type="hidden" name="add_record" value="Add Record">
<input type="submit" value="Add Record">





the <body was left off.......

btw I just used the # to tag the stuff that was already there.......

deleted the <INPUT TYPE="RESET" VALUE="$reset_button">

had to keep # <INPUT TYPE="SUBMIT" NAME="add_record" VALUE="$submit_button">&amp;nbsp;

otherwise I got an error ?


works fine now......well back to the forums to ask more question Sly.
Quote Reply
Re: [amfreak] Autosave record In reply to
amfreak,

Glad that I could help! Sly

Good luck on your journey to the perfect DB!





Anybody know where I can find a 1969 VW Beetle hardtop in perfect condition for under $100, blue with less than 100 miles on it?
beetlemanTongue

Marcus L. Griswold