Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript doesn't work on MAC

Status
Not open for further replies.

19511950

Programmer
Apr 4, 2003
46
US
I have simple code that doesn't work on MAC,but does on PC.

Please help.

<% Action1 = LEFT(UCASE(REQUEST("SAVE1")),4)
If Action1 = "SAVE" Then
Response.Write "You are here ":Response.End
End If%>

<HTML><HEAD>
<script language="javascript">
function DisSave() {
document.all.Approval.disabled=true;
document.all.Save1.click();
}
</script></HEAD>

<BODY>
<form action="T3.asp" method="POST" name="main1">
<INPUT type="submit" value="Send:" name="Approval" onclick="DisSave();">
<SELECT name=SENDTOLST><OPTION value="None">None</OPTION></SELECT>
<input type="submit" value="Save" name="Save1" style="visibility:hidden">
</form>
</BODY>
</HTML>
 
Try:

Code:
<script language="JavaScript">
function DisSave() {
    document.getElementById('Approval').disabled = true;
    document.getElementById('Save1').click();
}
</script></

or

Code:
<script language="JavaScript">
function DisSave() {
    document.forms['main1'].Approval.disabled = true;
    document.forms['main1'].Save1.click();
}
</script></

*cLFlaVA
----------------------------
Breaking the habit...
 
What isn't working about them?

*cLFlaVA
----------------------------
Breaking the habit...
 
If you put alert msg before and after button you will see
that code executed, but button doesn't click.

function DisSave() {

document.all.Approval.disabled=true;

alert("before button");
document.all.Save1.click();
alert("after button");
}
 
Try this:

Code:
<form action="T3.asp" method="POST" name="main1" onsubmit="DisSave();">
  <INPUT type="submit" value="Send:" name="Approval">
  <SELECT name=SENDTOLST>
    <OPTION value="None">None</OPTION></SELECT>
  <input type="submit" value="Save" name="Save1" style="visibility:hidden">   
</form>

*cLFlaVA
----------------------------
Breaking the habit...
 
Also, I don't believe you can click something that's hidden.

*cLFlaVA
----------------------------
Breaking the habit...
 
Have you thought that maybe the reason why is that you're not even using cLFlaVA's code? document.all is an IE only command which is probably why it's not working for the Mac. If you follow cLFlaVA's code from above by getting rid of the document.all from your code and referencing them in a different way then it might work. Here's my suggestion:
Code:
function DisSave() {
   document.forms['main1'].elements['Approval'].disabled=true;
   document.forms['main1'].elements['Save1'].click();
}

-kaht

banghead.gif
 
kaht-

I had noticed that. But then I took a step back and actually saw what he/she was trying to do: click a hidden button. I believe that's not possible. I also believe it would be easier to place the call to the function in the onsubmit event of the form, as I believe it's possible that disabling a button in it's own onclick event may cause problems.

Do you concur?

*cLFlaVA
----------------------------
Breaking the habit...
 
Any code doesn't work.
Maybe problem with the Mac browser 5.1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top