ASP button does not work when running from the script?

E

esoroka

Hello,

Trying to run a script what start ASP button:

document.Form1.all["btnNewPassUpdate"].click();

It is work one time only. Next script ignore it. Where can be
problem???

A full script is as follows:
<script language="javascript" type="text/javascript">
function ChangePass(NewPass)
{
var windowsize
"center:yes;dialogHeight:230px;dialogWidth:430px;toolbar:no;menubar:no;status:no;directories:no;scrollbars:no;location:no;resizable=no";

var retVal;
NewPass = window.showModalDialog("ChangePassword.aspx?","",windowsize);
if(NewPass !== "")
{
document.Form1.all["txbNewPass"].value = NewPass;
return document.Form1.all["btnNewPassUpdate"].click();
}
else return false;
}
</script>

Thanks,
eugene
 
K

kaeli

Hello,

Trying to run a script what start ASP button:

document.Form1.all["btnNewPassUpdate"].click();

You might want to get used to document.getElementById instead of
document.all.
It is work one time only. Next script ignore it. Where can be
problem???

A script error halting execution. Do you have MSIE set to display all script
errors? When developing, you should.
A full script is as follows:
<script language="javascript" type="text/javascript">
function ChangePass(NewPass)
{
var windowsize
"center:yes;dialogHeight:230px;dialogWidth:430px;toolbar:no;menubar:no;status:no;directories:no;scrollbars:no;location:no;resizable=no";

Missing an equal sign for assignment or something. Typo?
The above makes no sense.
var retVal;
NewPass = window.showModalDialog("ChangePassword.aspx?","",windowsize);
if(NewPass !== "")

!== ?
That is not valid as far as I know for javascript. You want != instead.
{
document.Form1.all["txbNewPass"].value = NewPass;
return document.Form1.all["btnNewPassUpdate"].click();

Um, what's that supposed to do?
Click is void.
Syntax
object.click()
Return Value
No return value.

Are you mixing up vb and javascript syntax and operators, perhaps?

--
 
E

esoroka

Ok. Thank you for the answer. Some remarks:
1. Do you have MSIE set to display all script errors?
No. Where can I get it? URL please. Thank you.
2. You might want to get used to document.getElementById instead of
document.all.
It does not matter because script can found the button. When I put
alerts before/after
this line it showed me that alert and also showed that object:
all["btnNewPass­Update"]
Moreover it perfectly worked before.
2. return document.Form1.all["btnNewPass­Update"].click(); Um, what's
that supposed to do?
It supposed to click a small ASP button. When I click it manually my
ASP code work well. But it ignore it in script in runtime. I also
tried the case like this:
document.Form1.all["ASPbtnName"].click();
return true;
same thing...
 
R

Random

I've also had some finicky behavior trying to use .click() methods.
Fortunately they're generally not necessary, so in general I work
around them.

If all you want is to submit the form, use the .submit() method of your
form element. If you want to call the onclick event handler for your
button, do so manually, then submit the form if appropriate.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top