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!

refused by Opera

Status
Not open for further replies.

namida

Programmer
May 29, 2003
101
AU
My page doesn't work when I tested in Opera. It works in IE though. I only have those two browsers

I took the code from one the forum
But it even refused alert.

Anyone knows what I'm doing wrong?

Code:
function subForm(){
   
  for (x=0; x<document.myForm.elements.length; x++){
    if (document.myForm.elements[x].value == &quot;&quot;){
      alert(&quot;Please fill in all blanks&quot;)
      return false;
    }
  }
  alert(&quot;Hello!&quot;);
  //now that we've checked the form, submit it to new window
  formWin = window.open(&quot;about:blank&quot;,&quot;formWin&quot;,&quot;height=420,width=470&quot;)
  document.myForm.action = &quot;tryout2.php&quot;
  document.myForm.method = &quot;post&quot;
  document.myForm.target = &quot;formWin&quot;
  document.myForm.submit()
}
</script>

<form name=&quot;myForm&quot;>
<input type=text name=&quot;f_name&quot;>
<input type=button value=&quot;Submit&quot; onClick=&quot;subForm()&quot;>
</form>

thanks!
 
notes from memory on Opera (not able to test now though)

alert needs to be window.alert

you have a return false; but do not call by return
eg:
onClick=&quot;return subForm()&quot;>

and no return true;


I am not sure you can dynamicaly change the form attributes in Opera this way but again this is from memory and connot test. possibly someone else can take that into a reply



____________________________________________________
get the best answer to your questions by asking the best questions &quot;General FAQ&quot; faq333-2924
onpnt2.gif
 
Thanks for the reply.
I tried window.alert .. didn't work as well :(

I'm using the version 7.1.

 
well, I guess looking at the slight things such as the missing &quot; &quot; could be tried
eg: (always surround values in&quot; &quot;)
<form name=&quot;myForm&quot;>
<input type=&quot;text&quot; name=&quot;f_name&quot;>
<input type=&quot;button&quot; value=&quot;Submit&quot; onClick=&quot;return subForm()&quot;>
</form>

I would add a alert to the opening of the function to see if it runs at all and is being called on the event. if this statement
if (document.myForm.elements[x].value == &quot;&quot;){
is true everytime then the return false may be preventing what I think you think you should see no matter what in this line
alert(&quot;Hello!&quot;);

so try this and see if the alert comes up
function subForm(){
window.alert(&quot;Hello!&quot;);


____________________________________________________
get the best answer to your questions by asking the best questions &quot;General FAQ&quot; faq333-2924
onpnt2.gif
 
Hi!
I surrounded everything with &quot; &quot; and also
moved the alert. It now looks like :

<script>
function subForm(){
window.alert(&quot;Hello!&quot;);
  for (x=0; x<document.myForm.elements.length; x++){
    if (document.myForm.elements[x].value == &quot;&quot;){
      window.alert(&quot;Please fill in all blanks&quot;)
      return false;
    }
  }

  //now that we've checked the form, submit it to new window
  formWin = window.open(&quot;about:blank&quot;,&quot;formWin&quot;,&quot;height=420,width=470&quot;)
  document.myForm.action = &quot;tryout2.php&quot;
  document.myForm.method = &quot;post&quot;
  document.myForm.target = &quot;formWin&quot;
  document.myForm.submit()
}
</script>

<form name=&quot;myForm&quot;>
<input type=&quot;text&quot; name=&quot;f_name&quot;>
<input type=&quot;button&quot; value=&quot;Submit&quot; onClick=&quot;return subForm()&quot;>
</form>

It works in IE again, still not working in Opera.

Thanks though!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top