• Check out the results of the Techtree Contest #19!
  • Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

Java code help.

Status
Not open for further replies.
Level 14
Joined
Aug 25, 2005
Messages
1,105
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:
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()" />
 
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>
 
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>
 
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.
Back
Top