473,320 Members | 1,707 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,320 software developers and data experts.

auto-submit form

Hey gang,

I have a login form that is empty by default, but can be filled with
values from a previous form:

<input type=text maxlength="40" size="40" name="user" value="`usr`">
<input type=password maxlength="8" name="password" value="`pss`">

where usr and pss are sent from the previous form.

I'd like to make a javascript function (I assume this is easy in
javascript) that automatically submits the form when usr and pss exist.
How would this be done?

Feb 21 '06 #1
5 17649
Navillus wrote:
Hey gang,

I have a login form that is empty by default, but can be filled with
values from a previous form:

<input type=text maxlength="40" size="40" name="user" value="`usr`">
<input type=password maxlength="8" name="password" value="`pss`">

where usr and pss are sent from the previous form.

I'd like to make a javascript function (I assume this is easy in
javascript) that automatically submits the form when usr and pss exist.
How would this be done?


Building on my previous post, I've looked up this much so far:
In the header, I put:

<head>
<script language="javascript">
function autoSubmit()
{
document.form.submit();
}
</script>
</head>

and then after the form, in the document, I put this:

<script language="JavaScript">
if (`usr`)
{
autoSubmit();
}
</script>
Now, when usr is present, it should trigger the if statement to be
true. And it is definatly showing up correctly; that is, when usr is
absent, the if statement is empty, but if usr is present, the if
statement is filled. But for some reason it isn't redirecting. Yikes!

Feb 21 '06 #2
Navillus wrote:
Navillus wrote:
Hey gang,

I have a login form that is empty by default, but can be filled with
values from a previous form:

<input type=text maxlength="40" size="40" name="user" value="`usr`">
<input type=password maxlength="8" name="password" value="`pss`">

where usr and pss are sent from the previous form.
Then you have minimal security.

I'd like to make a javascript function (I assume this is easy in
javascript) that automatically submits the form when usr and pss exist.
How would this be done?

Building on my previous post, I've looked up this much so far:
In the header, I put:

<head>
<script language="javascript">


The language attribute is deprecated, type is required.

function autoSubmit()
{
document.form.submit();
You have a form named 'form'?
}
</script>
</head>

and then after the form, in the document, I put this:

<script language="JavaScript">
if (`usr`)
That will always be true. Taken literally, you are asking if 'usr' is
not undefined, which it isn't so the test returns true.

Presuming that 'usr' is your shorthand for a reference to the value of
the input named 'user', then (based on the posted HTML) it will have a
value of - 'usr' - (quotes included) and so that will return true too.

{
autoSubmit();
}
</script>
Now, when usr is present, it should trigger the if statement to be
No, it will always be true so it will try to submit the form immediately
regardless.

true. And it is definatly showing up correctly; that is, when usr is
absent, the if statement is empty, but if usr is present, the if
statement is filled. But for some reason it isn't redirecting. Yikes!


What you have shown is an attempt to call the submit method of a form
with name/id of 'form'.

You haven't shown the actual form, how you try to get and insert values
for 'usr' or 'pss', or even what it is supposed to do onsubmit (what is
the value of the action attribute? does it use POST or GET?) so a
statement about what might happen when the submit method is called is
speculation.
--
Rob
Feb 22 '06 #3
RobG wrote:
Navillus wrote:
Navillus wrote:
Hey gang,

I have a login form that is empty by default, but can be filled with
values from a previous form:

<input type=text maxlength="40" size="40" name="user" value="`usr`">
<input type=password maxlength="8" name="password" value="`pss`">

where usr and pss are sent from the previous form.
Then you have minimal security.

I'd like to make a javascript function (I assume this is easy in
javascript) that automatically submits the form when usr and pss exist.
How would this be done?

Building on my previous post, I've looked up this much so far:
In the header, I put:

<head>
<script language="javascript">


The language attribute is deprecated, type is required.

function autoSubmit()
{
document.form.submit();


You have a form named 'form'?
}
</script>
</head>

and then after the form, in the document, I put this:

<script language="JavaScript">
if (`usr`)


That will always be true. Taken literally, you are asking if 'usr' is
not undefined, which it isn't so the test returns true.

Presuming that 'usr' is your shorthand for a reference to the value of
the input named 'user', then (based on the posted HTML) it will have a
value of - 'usr' - (quotes included) and so that will return true too.

{
autoSubmit();
}
</script>
Now, when usr is present, it should trigger the if statement to be


No, it will always be true so it will try to submit the form immediately
regardless.

true. And it is definatly showing up correctly; that is, when usr is
absent, the if statement is empty, but if usr is present, the if
statement is filled. But for some reason it isn't redirecting. Yikes!


What you have shown is an attempt to call the submit method of a form
with name/id of 'form'.

You haven't shown the actual form, how you try to get and insert values
for 'usr' or 'pss', or even what it is supposed to do onsubmit (what is
the value of the action attribute? does it use POST or GET?) so a
statement about what might happen when the submit method is called is
speculation.
--
Rob


Here's the jist of what I got so far. Something is still tripping it up
so it can't submit:

<script language="JavaScript">
function savecookie()
{
/* save the values of user and password of the form input
(document.form.elementname) in the cookie */
var url = "/sap/its/iacproject/select_premises.html";
var nextyear = new Date();
nextyear.setFullYear(nextyear.getFullYear() + 1);
document.cookie = 'password= '+ document.Login.password.value +
'# expires='+ nextyear.toGMTString() +'; path= /';
document.cookie = 'user= '+ document.Login.user.value + ';
expires=' + nextyear.toGMTString() +'; path= /';
}

function autoSubmit(){
document.Login.submit();
}
</script>

</head>

<body `SAP_BodyAttributes()` onload="`SAP_OnloadJavaScript()`">

<form name="Login" action="">

<table border=0 cellpadding=0 cellspacing=0 width=100%>
<br>
<br>
<tr>
<td width=5%></td>
<td>
<table border=0 cellpadding=2 cellspacing=2>
<tr>
<td align=right class=label>`#LoginID`
</td>
<td align=left>
<input type=text maxlength="40" size="40" name="user"
value="`usr`">
</td>
</tr>
<tr>
<td align=right class=label>`#Password`
</td>
<td align=left>
<input type=password maxlength="8" name="password" value="`pss`">
</td>
</tr>

<tr>
<td></td>
<td>
<input type=image name="~OkCode(LGON)"
SRC="`mimeURL(~name="button/login.gif")`" border=0

onclick="savecookie();">

</td>

</tr>

</table>

`if (~messageline != "")`

<table border=0>
<tr>
<td align=center class=message>`~messageline`
</td>
</tr>
</table>

`end`
</td>
</tr>

</form>
<script language="JavaScript">
var testUser = `usr`;
if (testUser != "")
{
savecookie(); <-- not sure if I should call this function, which
the normal form seems to do
autoSubmit(); <-- or this guy right here, neither seem to work
}
</script>

<script> document.Login.user.focus(); </script>
<p>

</p>
</body>

</html>
Now, there's some wierd SAP variable stuff in there, but trust me, when
the previous form sends the variable 'usr', calling `usr` puts it in
there correctly. It doesn't seem to matter though. I've tried like 5
different ways to test to see if usr exists, and none of them seem to
work. In fact, even if I just do something like if (1), it still won't
automatically submit. Well, it did once, but only when there wasn't a
value of usr. I'm thinking something like the <script>
document.Login.user.focus(); </script> is preventing it from
auto-submitting. I dont know. All help is appreciated. Thanks

Feb 22 '06 #4
Navillus wrote:
RobG wrote:
Navillus wrote:
Navillus wrote:
Hey gang,

I have a login form that is empty by default, but can be filled with
values from a previous form:

<input type=text maxlength="40" size="40" name="user" value="`usr`">
<input type=password maxlength="8" name="password" value="`pss`">

where usr and pss are sent from the previous form.
Then you have minimal security.
I'd like to make a javascript function (I assume this is easy in
javascript) that automatically submits the form when usr and pss exist.
How would this be done?
Building on my previous post, I've looked up this much so far:
In the header, I put:

<head>
<script language="javascript">


The language attribute is deprecated, type is required.
function autoSubmit()
{
document.form.submit();


You have a form named 'form'?

}
</script>
</head>

and then after the form, in the document, I put this:

<script language="JavaScript">
if (`usr`)


That will always be true. Taken literally, you are asking if 'usr' is
not undefined, which it isn't so the test returns true.

Presuming that 'usr' is your shorthand for a reference to the value of
the input named 'user', then (based on the posted HTML) it will have a
value of - 'usr' - (quotes included) and so that will return true too.
{
autoSubmit();
}
</script>
Now, when usr is present, it should trigger the if statement to be


No, it will always be true so it will try to submit the form immediately
regardless.
true. And it is definatly showing up correctly; that is, when usr is
absent, the if statement is empty, but if usr is present, the if
statement is filled. But for some reason it isn't redirecting. Yikes!


What you have shown is an attempt to call the submit method of a form
with name/id of 'form'.

You haven't shown the actual form, how you try to get and insert values
for 'usr' or 'pss', or even what it is supposed to do onsubmit (what is
the value of the action attribute? does it use POST or GET?) so a
statement about what might happen when the submit method is called is
speculation.
--
Rob

Here's the jist of what I got so far. Something is still tripping it up
so it can't submit:

<script language="JavaScript">


The language attribute is (still) deprecated, type is required.

<script type="text/javascript">

function savecookie()
{
/* save the values of user and password of the form input
(document.form.elementname) in the cookie */
var url = "/sap/its/iacproject/select_premises.html";
The 'url' variable is not used - is it supposed to be?

var nextyear = new Date();
nextyear.setFullYear(nextyear.getFullYear() + 1);
document.cookie = 'password= '+ document.Login.password.value +
'# expires='+ nextyear.toGMTString() +'; path= /';
document.cookie = 'user= '+ document.Login.user.value + ';
expires=' + nextyear.toGMTString() +'; path= /';
Don't let your code auto-wrap. Manually wrap at about 70 characters or
errors like this are introduced.

From what you have posted, the value of 'user' will be - `usr` - and
the value of password will be - `pss` - always (presuming that the form
does actually auto-submit). I don't think that is what is intended.

You don't appear to ever get values for user and password from the
cookie (or anywhere else) to put into the form.

}

function autoSubmit(){
document.Login.submit();
}
</script>

</head>

<body `SAP_BodyAttributes()` onload="`SAP_OnloadJavaScript()`">
That is invalid HTML. `SAP_BodyAttributes()` is an attribute value with
no name. You are feeding onload a string literal, whereas it requires a
function call or script statements. The above also causes illegal
character errors in Firefox unless the ` character is replaced with '.

I get the feeling this is sever code that you are trying to generate
client code from.

<form name="Login" action="">

<table border=0 cellpadding=0 cellspacing=0 width=100%>
<br>
<br>
<tr>
<td width=5%></td>
<td>
<table border=0 cellpadding=2 cellspacing=2>
<tr>
<td align=right class=label>`#LoginID`
</td>
<td align=left>
<input type=text maxlength="40" size="40" name="user"
value="`usr`">
The input has a value of the string literal `usr`. Nothing you have
posted shows how any other value might get in there.

</td>
</tr>
<tr>
<td align=right class=label>`#Password`
</td>
<td align=left>
<input type=password maxlength="8" name="password" value="`pss`">
The input has a value of the string literal `pss`. Nothing you have
posted shows how any other value might get in there.

</td>
</tr>

<tr>
<td></td>
<td>
<input type=image name="~OkCode(LGON)"
Weird name, looks more like a function call.

SRC="`mimeURL(~name="button/login.gif")`" border=0
More invalid HTML with incorrect nesting of quotes.


onclick="savecookie();">

</td>

</tr>

</table>

`if (~messageline != "")`
Is this supposed to be displayed in the page? More server code?

<table border=0>
<tr>
<td align=center class=message>`~messageline`
More server code?

</td>
</tr>
</table>

`end`
Ditto.

</td>
</tr>

</form>
<script language="JavaScript">
The language attribute is (still) deprecated, type is required.

<script type="text/javascript">

var testUser = `usr`;
if (testUser != "")
Considering that you initialise testUser with a string literal, this
test will *always* be false. I suspect that the server is supplying a
value for `usr`.

{
savecookie(); <-- not sure if I should call this function, which
the normal form seems to do
Calling savecookie() makes no difference at all (I'll guess that the
comment is there only for posting, it will cause an error if it's in the
actual source).

autoSubmit(); <-- or this guy right here, neither seem to work
This will do nothing. The submit function (as posted previously) is:

function autoSubmit()
{
document.form.submit();
}
There is no form called 'form', the one you want to submit is called
'Login'. You should allow the form name to be passed to autosubmit() or
just call submit from here:

document.forms['Login'].submit();
But given the stuff above, if that does work (it will never be called at
present because the if test always fails) the page will continuously
submit itself in a never-ending loop.

}
</script>

<script> document.Login.user.focus(); </script>
<p>

</p>
</body>

</html>
Now, there's some wierd SAP variable stuff in there, but trust me, when
the previous form sends the variable 'usr', calling `usr` puts it in
there correctly. It doesn't seem to matter though. I've tried like 5
different ways to test to see if usr exists, and none of them seem to
work. In fact, even if I just do something like if (1), it still won't
automatically submit. Well, it did once, but only when there wasn't a
value of usr. I'm thinking something like the <script>
document.Login.user.focus(); </script> is preventing it from
auto-submitting.
Unlikely. If the script works then the form will be submitted before
that line is reached. If the form isn't submitted, then focus is put
onto the 'user' input.

I dont know.


Nor do I. Seems to me you are posting what you think the browser is
getting based on munged server code (but maybe that's wrong). Use your
browser's view source function to get the actual code received at the
client, then you might have a chance of making it work.

Otherwise little more help can be provided unless someone understands
what should be happening with your server code.

--
Rob
Feb 22 '06 #5
Navillus wrote:
I have a login form that is empty by default, but can be filled with
values from a previous form: [...]


You should have continued the corresponding thread, that would have
explained much to those who were not familiar with your SAP template
already.
PointedEars
Feb 22 '06 #6

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

Similar topics

2
by: Manlio Perillo | last post by:
Hi. This post follows "does python have useless destructors". I'm not an expert, so I hope what I will write is meaningfull and clear. Actually in Python there is no possibility to write code...
1
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the...
5
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge...
20
by: Vijay Kumar R. Zanvar | last post by:
Hello, Unlike register, auto keyword can not be used to declare formal parameter(s). Is there any specific reason for this? Kind regards, Vijay Kumar R. Zanvar
6
by: Alpha | last post by:
I retrieve a table with only 2 columns. One is a auto-generated primary key column and the 2nd is a string. When I add a new row to the dataset to be updated back to the database. What should I...
5
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the...
5
by: maya | last post by:
at work they decided to center divs thus: body {text-align:center} #content {width: 612px; text-align:left; margin: 0 auto 0 auto; } this works fine in IE & FF, EXCEPT in FF it doesn't work if...
22
by: nospam_news | last post by:
I currently get asked about my usage of "auto". What is it for? The keyword is clearly superflous here. In contrast to the huge majority of C/C++ developers I write definitions very explicitly...
2
by: Piotr K | last post by:
Hi, I've encountered a strange problem with Firefox which I don't have any idea how to resolve. To the point: I've <divelement with a style "height: auto" and I want to retrieve this value...
21
by: JOYCE | last post by:
Look the subject,that's my problem! I hope someone can help me, thanks
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.