• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Java code help.

Status
Not open for further replies.
Level 14
Joined
Aug 25, 2005
Messages
1,133
javascript help

I've never programed in javascript before so i was messing around with it but for some reason i can't get this simple alert button to work...


Code:
<form action="">

<input type="button" value="click!">
onclick="Alert1()"/>

</forum>

<script type="text/javascript">

<!--//

{

Function alert1()

alert="test!!"

}

//-->

</script>
 
Last edited:
Level 8
Joined
Dec 11, 2006
Messages
218
madcat2 said:
I've never programed in javascript before so i was messing around with it but for some reason i can't get this simple alert button to work...

I noticed a couple of errors in your script .. I'll post one that works then you can compare the differences your self.. If ya still don't get then just give me a PM and I'll help ya out..

Code:
<script type="text/javascript">
function alertbox(){
  alert("Hello World!");
}
</script>

<input type="button" value="Click here" onclick="alertbox()" />
 
Level 8
Joined
Oct 8, 2005
Messages
409
Can you also debug mine?
I have also never writen in javascript before, but am trying to get this image to appear if a srting contains a another sub string with index 0,6.
Code:
<script language="javascript" type="text/javascript"> 
   var vName=''; 
   var olStatus=0; 
   if(document.getElementById("mininav-avname")) 
      { 
      allTags=document.getElementById('mininav-avname').innerHTML; 
          if(allTags.indexOf("Guest") == 0) 
             { 
             if(vName!='') 
                 {  
                 olStatus=1; 
                 } 
             if(olStatus==1)  
                 { 
                 document.write('<Br/><Br/><Br/><img src="http://helios.gsfc.nasa.gov/image_euv_press.jpg"><Br/><Br/><Br/>'); 
                 } 
      } 
</script>
 
Level 15
Joined
Nov 1, 2004
Messages
1,058
Can you also debug mine?
I have also never writen in javascript before, but am trying to get this image to appear if a srting contains a another sub string with index 0,6.
Code:
<script language="javascript" type="text/javascript"> 
   var vName=''; 
   var olStatus=0; 
   if(document.getElementById("mininav-avname")) 
      { 
      allTags=document.getElementById('mininav-avname').innerHTML; 
          if(allTags.indexOf("Guest") == 0) 
             { 
             if(vName!='') 
                 {  
                 olStatus=1; 
                 } 
             if(olStatus==1)  
                 { 
                 document.write('<Br/><Br/><Br/><img src="http://helios.gsfc.nasa.gov/image_euv_press.jpg"><Br/><Br/><Br/>'); 
                 } 
      } 
</script>
You are one "}" short. Try placing an extra one before the </script>

Code:
<script language="javascript" type="text/javascript"> 
   var vName=''; 
   var olStatus=0; 
   if(document.getElementById("mininav-avname")) 
      { 
      allTags=document.getElementById('mininav-avname').innerHTML; 
          if(allTags.indexOf("Guest") == 0) 
             { 
             if(vName!='') 
                 {  
                 olStatus=1; 
                 } 
             if(olStatus==1)  
                 { 
                 document.write('<Br/><Br/><Br/><img src="http://helios.gsfc.nasa.gov/image_euv_press.jpg"><Br/><Br/><Br/>'); 
                 }
            }
      } 
</script>
 
Level 8
Joined
Oct 8, 2005
Messages
409
Thanks, oK that works now.

But, I am having some trouble getting the script to write css.

Code:
<script language="javascript" type="text/javascript"> 
var vName=''; 
var olStatus=0; 
if(document.getElementById("mininav-avname")) { vName=document.getElementById("mininav-avname").innerHTML; 
if(vName!='') {olStatus=1; } 
var vSrc='http://www.imvu.com/catalog/web_av_pic.php?av='+vName;var vHref='http://avatars.imvu.com/'+vName;} 
if(olStatus==0) {var vName = "ooooooooooooooo"; }   
vName = vName.substring(0,5);   
if(vName == "Guest"){document.write('<style type="text/css">
#url_panel, .imvucodes_net { display:none !important; }
</style>');}
</script>
 
Status
Not open for further replies.
Top