Jump to content

jnutty1

Members
  • Posts

    8
  • Joined

  • Last visited

jnutty1's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. hotwheels,The random function will return a number between 0 and 1. var ry=Math.floor(Math.random()*myvideos.length) This returns a value between 0 and 2.Since the array, myvideos, uses element 1 and 2 and there is code to change the value of ry to 1 if ry=0, myvideos[0] would never be accessed since ry cannot equal 0.To use myvideos[0] you would have to change the lines of code if (ry==0) ry=1 to if (ry==myvideos.length) ry=myvideos.length-1
  2. hotwheels,The random image routine does work. Here is the code for your random video box. This has to be added in the cell you want it to display in. <script language="JavaScript"> <!-- function random_vidlink(){ var myvideos=new Array() myvideos[1]="http://www.youtube.com/v/RIW_K-YrEIQ" myvideos[2]="http://www.youtube.com/v/1iqOkrnJQjQ" var ry=Math.floor(Math.random()*myvideos.length) if (ry==0) ry=1 document.write('<object><param name=\'allowScriptAccess\' value=\'sameDomain\' /><param name=\'movie\' value=\''+myvideos[ry]+'\' /> <param name=\'flashVars\' value=\''+myvideos[ry]+'\' /> <param name=\'quality\' value=\'high\' /><param name=\'bgcolor\' value=\'#686F7E url(http://www.insanemustangs.com/forums/images/gradients/Slate.jpg)\' /><embed src="'+myvideos[ry]+'" type="application/x-shockwave-flash" wmode="transparent" width="125" height="150" quality=\'high\' bcolor=\'#686F7E url(http://www.insanemustangs.com/forums/images/gradients/Slate.jpg)\' name=\'\' align=\'center\' allowScriptAccess=\'sameDomain\' pluginspage=\'http://www.macromedia.com/go/getflashplayer\' /></object>');}random_vidlink() //-->" </script> jnutt
  3. Hi,I have a problem with creating an AJAX object. I took the code that is in the AJAX section of this site and it worked just fine. But, if I create an object of the same code (see below) the onreadystatechange function doesn't seem to recognize elements in the object. function sendData(smethod,surl,sdata,basync,index){ this.GetXmlHttpObject=GetXmlHttpObject; this.index=index; this.xmlHttp=this.GetXmlHttpObject() if (this.xmlHttp==null) { alert ("Browser does not support HTTP Request") } if (smethod.toUpperCase()=="GET" && sdata.length>0){ surl+="?"+sdata; sdata=null; } this.xmlHttp.onreadystatechange=function(){ if (this.xmlHttp.readyState==4 || this.xmlHttp.readyState=="complete") { doResponse(this.xmlHttp.responseText,this.index); } } this.xmlHttp.open(smethod,surl,basync);this.xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");this.xmlHttp.send(sdata);} function GetXmlHttpObject(){ var xmlHttp=null; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { //alert("Your browser does not support AJAX!"); } } }return xmlHttp;} The javascript code to create the objects would be as follows: var aj=new Array();function test(){ aj[0]=new sendData('POST','pagea.php','id=1',true,0) aj[1]=new sendData('POST','pageb.php','id=2',true,1)}function doResponse(s,index){ do something with s. aj[index]=null;} Each time a sendData object is created and the onreadystatechange function executes, an error stating that this.xmlHttp.readyState is null or not an object (in IE) or it doesn't have any properties (in netscape, firefox).Any thought would be appreciated.
  4. Tanis,Change your Option lines to read as follows <option value='HC.php'>Habbo Club</option> Also, add this id to your select line. <select name="changeDiv" id="changeDiv"> In the function open_page, change request.open("get", ""+document.forms['selectForm'].selection.value+""); to request.open("get", document.getElementById("changeDiv").options[document.getElementById("changeDiv").selectedIndex].value,true); When you click the "Go" button, the open_page function will get the value of the selected option and use it as the URL for the page you want to retrieve.
  5. Obi1,The code you have will work as long as the value in $k2 will create a valid form name. If $k2 contains spaces, special characters, etc., it will fail.
  6. Prateek,In your xline function, change the line:gfxLib.innerHTML='<div id="'+name+'" style="position:absolute;padding:0px;margin:0px;height:5px;"></div>'; to gfxLib.innerHTML+='<div id="'+name+'" style="position:absolute;padding:0px;margin:0px;height:5px;overflow:hidden"></div>'; I added a "+" so you can see the box drawn and "overflow:hidden" style so the div will not expand past the height that has been set by the height property.
×
×
  • Create New...