Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts

    link to anchor from select box

    I'm trying to link to an anchor from a select box. Unfortunatly it isn't working. It just puts the parent page into the Iframe. I should note that the body is being written into the iframe from the parent page. The function is held in the parent and called from the iframe. This is the code I have.

    // this code is in the parent frame

    <script language="javascript">
    function jumpDate()
    {
    URL=window.pane.main.datebox.options[window.pane.main.datebox.selectedIndex].value;
    pane.location.href="#"+URL; // I think this is where I'm going wrong is there a different way to state this so that it just jumps to the anchor?
    }
    </script>

    // this code is in the <iframe> created from code in the parent (not shown)

    <body>
    <form name="main">
    <select name="datebox" onchange="parent.jumpDate()">
    <option value="27">
    <option value="28">
    <option value="29">
    <option value="30">
    </select>

    <a name="27">27th</a>
    <a name="28">28th</a>
    <a name="29">29th</a>
    <a name="30">30th</a>
    </form>
    </body>

    TIA
    Basscyst
    Last edited by Basscyst; 10-27-2003 at 11:45 PM.
    Helping to build a bigger box. - Adam Matthews

  • #2
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    OK it seems this is kind of working but only after I have selected from the dropdown
    and then it loads the parent page in the iframe.
    Then once I press the button to have the iframe
    repopulated it works as it should. I'm tottaly lost at the reason for this.
    Here is my complete code please bare with me as it's kind of big. It will not actually work as it is
    contigent on there being files on the local file system.
    The parts I'm having difficulty with are bolded.

    Code:
    <html>
    <head>
    <style>
    .btn {
    	font-size:11px; 
    	font-family: Arial, Helvetica, sans-serif;
    	background-color: #E5E5E5; 
    	border-left: 1 solid #9D766D;
    	border-right: 1 solid #9D766D;
    	border-bottom: 1 solid #9D766D;
    	border-top: 1 solid #9D766D;
    	filter:progid:DXImageTransform.Microsoft.Fade(duration=0.2,overlap=1.0);
    	cursor:hand;	
    	width:83px;
    	height:22px;
    	}
    </style>
    
    
    
    <script language="javascript">
    
    var reqDest=("G:\\ss-prepay\\ot_tracking\\Requested\\");
     var logDest=("G:\\ss-prepay\\ot_tracking\\Logged OT\\");
      var dataDest=("G:\\ss-prepay\\ot_tracking\\");
       var dataBasea=new Array();
         var dataBaseb=new Array();
           var dataBasec=new Array();
       	var MainData=new Array();
           var SpanishData=new Array();
          var SupportData=new Array();
         var temp="";
        var sfo=new ActiveXObject("scripting.FileSystemObject");
       var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
      var j=0;
     var button="temp";
    
    function transbutton(obj,onoff) 
    {
    	    obj.filters[0].Apply();
    	    if (onoff == 1) 
    	    {
    	    	//on
    	    	obj.style.background = "#B3C7EC";
    	    	obj.style.color = "#000000";
    	    }
    	    else 
    	    {
    	    	//off
    	    	obj.style.background = "#E5E5E5";	    	
    	    	obj.style.color = "#000000";
    	    }
    	    obj.filters[0].Play();
    }
    
    
    	
    function countup(yr,m,d) 
    {
    var today=new Date();
     var todayy=today.getYear();
      var todaym=today.getMonth();
       var todayd=today.getDate();
      var todaystring=montharray[todaym]+" "+todayd+", "+todayy;
     var paststring=montharray[m-1]+" "+d+", "+yr;
    difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1);
    }
    
    function getTime(){
     var when=new Date();
      var month=when.getMonth() + 1;
       var day=when.getDate();
        var year=when.getYear();
         var hour=when.getHours();
        var minutes=when.getMinutes();
       var seconds=when.getSeconds();
    
    
    //Fix Time So >10 has a 0
    
    	if (seconds<10){
    		seconds="0" + seconds
    	}
    	if (minutes<10){
    	minutes="0" + minutes
    	}
    	
    time=(month + "-" + day + "-" + year + " " + hour + ":" + minutes + ":" + seconds);
    }
    getTime();
    
    function checkFiles(array)
    {
           checkFile=sfo.FileExists(reqDest +array[j][0]+".txt");
    	 checkFile2=sfo.FileExists(logDest+array[j][0]+".txt");
    }
    
    function checkFiles2(array)
    {
           checkFile3=sfo.FileExists(reqDest +array[i][0]+".txt");
    	 checkFile4=sfo.FileExists(logDest+array[i][0]+".txt");
    }
    
    function clearIt(){
    pane.document.body.innerHTML="";
    }
    	
    function getRecords(database,db,array,but)
    {
    button=but;
    document.getElementById('buts').style.visibility="visible";
    	
    	 var getFile=sfo.OpenTextFile(dataDest + db,1,false,0);
    	  var str=getFile.ReadAll();
    	 var cut2=str.split("\n");
    		
    	for (i=0;i<cut2.length-2;i++)
    	{
    		var cut1=cut2[i].split("|");
    	 	 var shift_id=cut1[0];
    	 	  var shift_time=cut1[1];
    	 	  var shift_date=cut1[2];
    	 	  var split_time=shift_date.split("-");
    	 	 var monthx=split_time[0];
    	 	var dayx=split_time[1];
    	      var yearx=split_time[2];
    	      countup(yearx,monthx,dayx);
    	      temp=difference;
    	     database[i]=new Array(shift_id,shift_time,shift_date,temp,"","","","");
    
    	     	if(database[i][3]<0)
         		{
         		array[j]=database[i];
           		array[j][7]="<input type='checkbox'>";
         		array[j][4]="Shift Open";
         		array[j][6]="Shift Open";
         		
         		checkFiles(array);
         		
         			if (checkFile==true)
         			{
         			 var getRecord=sfo.OpenTextFile(reqDest + array[j][0] + ".txt",1,false,0);
    			  var str2=getRecord.ReadAll();
    			   var cut3=str2.split("*");
    			    var rockwell=cut3[0];
    			     var name=cut3[1];
    			     var date_time=cut3[2];
    			    array[j][4]=rockwell;
    			   array[j][5]=name;
    			  array[j][6]=date_time;
    			  getRecord.Close();
    			 
         			}
            j=j+1;} 	
    	}
    for(q=1;q<array.length;q++){
    		 r=q-1;
    	  	 look1=array[q][2].split("-");
    	  	 look2=array[r][2].split("-");
    	  	  
    	  		if(look1[1]>look2[1]){
    	  			array[q][2]=('<a name="' + look1[1] + '">' + array[q][2] + '</a>');
    	  		}
    	}displayShifts(array);j=0;}
    
    function Admin()
    {
    pass=prompt("Please enter the password.","");
    	if (pass=="1xrt")
    	{
    	imtname=prompt("Please enter your name.","");
    	document.getElementById('admin').style.visibility="visible";
    	}
    	else
    	{
    	alert("Log-In Failed!");
    	}
    }		      
    
    
    function displayShifts(array){
    clearIt();
    cue=array;
    tempstr='<a href="#30">AAAA</a><form name="main"><table border=1 width="100%" style="text-align:center;"><thead><th><img src="djk"><th><select name="datebox" onchange="parent.jumpDate()"><option>Date:<option value="01">1st<option value="02">2nd<option value="03">3rd<option value="04">4th<option value="05">5th<option value="06">6th<option value="07">7th<option value="08">8th<option value="09">9th<option value="10">10th<option value="11">11th<option value="12">12th<option value="13">13th<option value="14">14th<option value="15">15th<option value="16">16th<option value="17">17th<option value="18">18th<option value="19">19th<option value="20">20th<option value="21">21st<option value="22">22nd<option value="23">23rd<option value="24">24th<option value="25">25th<option value="26">26th<option value="27">27th<option value="28">28th<option value="29">29th<option value="30">30th<option value="31">31st</select><th>Time<th>Rockwell ID<th>Request Date</th></thead>'
    	
    	function displayColor(color)
    	{
    	tempstr+=("<tr><td>" + array[i][7] + "<td>" + array[i][2] + "<td>" + array[i][1] + "<td style='color:" + color + "'>" + array[i][4] + "<td style='color:" + color + "'>" + array[i][6] + "</td></tr>");
    	}
    	for(i=0;i<array.length;i++)
    	{
    	checkFiles2(array);
    		if(checkFile4==true)
    		{
    		displayColor('black');
    		}
    		else if(checkFile3==true&&checkFile4==false)
    		{
    		displayColor('red');
    		}
    		else
    		{
    		displayColor('green');
    		}
    	}
    tempstr+=("</table></form>");
    pane.document.body.innerHTML=tempstr;
    }
    
    function getChecked(){
    is_checked=window.pane.document.main.elements[i].checked;
    }
    
    function chooseShifts(cue,divID,header,msg)
    {
    if(document.getElementById('rockwell').value=="")
    {
    alert("Please enter your Rockwell ID & Name");
    }
    else
    {
    divID.innerHTML="<font color='white'><u><b>" + header + "</b></u></font><br>";
    	for(i=0;i<cue.length;i++)
    	{
    		getChecked();
    		
    			if(is_checked==true)
    			{
    				checkFiles2(cue);
    				
    					if(checkFile3==true)
    					{
    						divID.innerHTML+="<font color='red'>" + cue[i][1] + " on " + cue[i][2] + " Failed!<br>";
    					}
    					else
    					{
    						divID.innerHTML+=cue[i][1] + " on " + cue[i][2] + "<font color=green>" + msg + "</font><br>"; 
    					}
    					if(checksub==1)
    					{
    					checkFiles2(cue)
    						if (checkFile3==false)
    						{
    						var fileLoc=sfo.CreateTextFile(reqDest + cue[i][0] + ".txt",false);
    						fileLoc.WriteLine(parent.document.getElementById("rockwell").value + '*' + parent.document.getElementById("name").value + "*" + time);
    						fileLoc.Close();
    						}
    					
    					
    					}
    			}
    	}
    	if(checksub==0)
    	{
    	choices.innerHTML+="<br><input type='button' class='btn' ONMOUSEOVER='JAVASCRIPT: transbutton(this, 1);' ONMOUSEOUT='JAVASCRIPT: transbutton(this, 0)' value='Submit' onclick=javascript:checksub=1;chooseShifts(cue,submitted,'Submitted&nbsp;Shifts:','Submitted')>";
    	}
    	else
    	{
    	choices.innerHTML="<font color=white>Selected Shifts:</font><br>Your selected shifts have been submitted";button.click();return false;
    	}
    }
    }
    
    function cancelReq(cue){
    	for(i=0;i<cue.length;i++)
    	{
    		getChecked();
    	
    		if(is_checked==true)
    		{
    			checkFiles2(cue);
    			
    			if (checkFile4==true)
    			{
    			        sfo.DeleteFile(logDest + cue[i][0] + ".txt", true);
    				sfo.DeleteFile(reqDest + cue[i][0] + ".txt", true);
    			}
    			else
    			{
    				sfo.DeleteFile(reqDest + cue[i][0] + ".txt", true);
    			}
     		}
     	}button.click();return false;
    
    }
    
    function displayUnlogged(cue)
    {
    nextUnlogged(cue);
    if(nextrep=="None")
    {
    alert("No Unlogged Shifts")
    }
    else
    {
    document.getElementById('rockwell').value=nextrep;
    myWindow=window.open("","myWindow","status=no,location=yes,toolbar=yes,directories=no,resizable=yes,width=600,height=400,top=100,left=100,scrollbars=yes");
     myWindow.document.open();
    myWindow.document.writeln("<center><table border=1 bgColor=C3DEF1 style='text-align:center;' width=500><tr><td><b>Shift Time<td><b>Date<td><b>Name<td><b>ID<td><b>Time Requested</b></td></tr>");    
    	for(i=0;i<cue.length;i++){
    		checkFiles2(cue);
    			if (checkFile3==true && checkFile4==false)
    			{
    						
    str="<tr><td>" + cue[i][1] + "<td>" + cue[i][2] + "<td>" + cue[i][5] + "<td>" + cue[i][4] + "<td>" + cue[i][6] + "</td></tr>";
    						
    				if (parent.document.getElementById('rockwell').value==cue[i][4])
    				{
    					myWindow.document.writeln(str);
    					window.pane.document.main.elements[i].checked=true;
    				}
    		
    			}
    	
    	}
      		
      		
      myWindow.document.writeln("</table><br><input type='button' value='Mark As Logged' onclick=javascript:parent.opener.focus();parent.opener.markLogged(parent.opener.cue)> ");
    myWindow.document.close();
    }
    }
    
    function markLogged(cue)
    {
    myWindow.close();
    	for(i=0;i<cue.length;i++)
    	{
    		getChecked();
    	
    		if(is_checked==true)
    		{
    			  fileLoc=sfo.CreateTextFile(logDest + cue[i][0] + ".txt",false);
    			 fileLoc.WriteLine(cue[i][1] + "|" + cue[i][2] + "|" + cue[i][5] + "|" + imtname + "|" + time);
    			fileLoc.Close()
    		}
     	}button.click();return false;
     }
    
    function nextUnlogged(cue)
    {
    
    	for(i=0;i<cue.length;i++)
    	{
    	checkFiles2(cue);
    		if(checkFile3==true&&checkFile4==false)
    		{
    		nextrep=cue[i][4];
    		return;
    		}
    		else
    		{
    		nextrep="None"
    		}
    	}
    }
    
    function showMine(cue)
    {
    var myshifts="";
    	if(document.getElementById('rockwell').value=="")
    	{
    	alert("Please Enter Your Rockwell ID")
    	}
    	else
    	{
    	newWindow=window.open("","myWindow","status=no,location=yes,toolbar=yes,directories=no,resizable=yes,width=600,height=400,top=100,left=100,scrollbars=yes");
    	newWindow.document.open();
    	newWindow.document.writeln("<center><table border=1 bgColor=C3DEF1 style='text-align:center;' width=500><tr><td><b>Shift Time<td><b>Date<td><b>Name<td><b>ID<td><b>Time Requested</b></td></tr>");    
    	
    		for(i=0;i<cue.length;i++)
    		{
    			if(cue[i][4]==document.getElementById('rockwell').value)
    			{
    			myshifts="<tr><td>" + cue[i][1] + "<td>" + cue[i][2] + "<td>" + cue[i][5] + "<td>" + cue[i][4] + "<td>" + cue[i][6] + "</td></tr>";
    			newWindow.document.writeln(myshifts);
    			}
    		}
    	}newWindow.document.writeln("</table><center><div style='cursor:hand' onclick=this.style.visibility='hidden';window.print();><img src='printer.gif'><br>Print Shifts</div>");
    newWindow.document.close();
    }
    			
    function jumpDate()
    {
    URL=window.pane.main.datebox.options[window.pane.main.datebox.selectedIndex].value;
    window.pane.location.href="#"+URL;
    }
    	
    
    </script>
    </head>
    <body>
    <div style="position:absolute;left:388px;top:79px;z-index:1;"><b><font color="2E8BCE">Select a group to view available shifts.</font></b>
    </div>
    
    <img src="http://10.32.17.239:8001/asrv/Assets/AssetServer/SiteAssets/PrepaidInfoManager/top_curv.JPG" style="position:absolute;left:318px;top:22px;width:388px">
    <img src="http://10.32.17.239:8001/asrv/Assets/AssetServer/SiteAssets/PrepaidInfoManager/OTheader.jpg" style="position:absolute;left:5px;top:35px;">
    
    <div id="right">
    <img src="http://10.32.17.239:8001/asrv/Assets/AssetServer/SiteAssets/PrepaidInfoManager/vzw_logo.gif" style="position:absolute;left:700px;top:25px;">
    </div>
    
    <img src="http://10.32.17.239:8001/asrv/Assets/AssetServer/SiteAssets/PrepaidInfoManager/btm_crv.JPG" style="position:absolute;left:318px;top:78px;width:388px">
    <img src="http://10.32.17.239:8001/asrv/Assets/AssetServer/SiteAssets/PrepaidInfoManager/bgimg.jpg" style="position:absolute;left:6px;top:120px;width:990px">
    
    <div id="all" style="position:absolute;top:45px;left:318px;">
    <center>
    
    <table bgColor="C3DEF1" id="top" border=1 width="388">
    <tr><td>
    <b>Rockwell ID: <input type="text" id="rockwell" size="6">  
    <td><b>Full Name:</b> <input type="text" id="name" size="15">
    </table>
    
    <input type="button" class="btn" ONMOUSEOVER="JAVASCRIPT: transbutton(this, 1);" ONMOUSEOUT="JAVASCRIPT: transbutton(this, 0)"  style=";position:relative;left:0px;top:45px;" class="btn" ONMOUSEOVER="JAVASCRIPT: transbutton(this, 1);" ONMOUSEOUT="JAVASCRIPT: transbutton(this, 0)" value="Spanish" name="spbut" onclick="getRecords(dataBasea,'dbspanish.txt',SpanishData,spbut);">
    <input type="button" class="btn" ONMOUSEOVER="JAVASCRIPT: transbutton(this, 1);" ONMOUSEOUT="JAVASCRIPT: transbutton(this, 0)" style="position:relative;left:0px;top:45px;" value="Main Floor" name="mainbut" onclick="getRecords(dataBaseb,'dbmain.txt',MainData,mainbut);">
    <input type="button" class="btn" ONMOUSEOVER="JAVASCRIPT: transbutton(this, 1);" ONMOUSEOUT="JAVASCRIPT: transbutton(this, 0)" style="position:relative;left:0px;top:45px;" value="Support" name="supbut" onclick="getRecords(dataBasec,'dbsupport.txt',SupportData,supbut);">
    <input type="button" class="btn" ONMOUSEOVER="JAVASCRIPT: transbutton(this, 1);" ONMOUSEOUT="JAVASCRIPT: transbutton(this, 0)" style="position:relative;left:0px;top:45px;" value="IMT Admin." name="adbut" onclick="Admin();">
    
    <br>
    
    <iframe src="" id="pane" height="265" width="360" frameBorder=0 style="position:absolute;left:8px;top:103px;"></iframe>
    </div>
    
    <div id="buts" style="position:absolute;top:420px;left:306px;width:415px;visibility:hidden;text-align:center;">
    <input type="button" class="btn" ONMOUSEOVER="JAVASCRIPT: transbutton(this, 1);" ONMOUSEOUT="JAVASCRIPT: transbutton(this, 0)" value="Save Selections" onclick="checksub=0;chooseShifts(cue,choices,'Selected Shifts:','');">&nbsp;<input type="button" class="btn" ONMOUSEOVER="JAVASCRIPT: transbutton(this, 1);" ONMOUSEOUT="JAVASCRIPT: transbutton(this, 0)" value="View My Shifts" onclick="showMine(cue)">
    
    <br>
    <br>
    
    <div id="admin" style="visibility:hidden;">
    &nbsp;&nbsp;
    <input type="button" class="btn" ONMOUSEOVER="JAVASCRIPT: transbutton(this, 1);" ONMOUSEOUT="JAVASCRIPT: transbutton(this, 0)" value="Cancel Request" onclick="cancelReq(cue);">
    
    <a href="#" onclick="displayUnlogged(cue);"><input type="button" class="btn" ONMOUSEOVER="JAVASCRIPT: transbutton(this, 1);" ONMOUSEOUT="JAVASCRIPT: transbutton(this, 0)" value="View Unlogged"></a>
    
    </div>
    </div>
    
    <br>
    
    <div style="position:absolute;top:530px;left:25px;">If you require a bridge for your OT selections,  a shift in a 1\2 hour increment, or if you wish to sign up for the current day you will need to contact IMT directly.
    </div>
    
    <div id="choices" style="width:285px;height:;position:absolute;top:128px;left:15px;">
    <b><u><font color="white">Selected Shifts:</font></u></b>
    
    <br>
    
    <i>You have not selected any shifts in this session.</i>
    </div>
    
    <div id="submitted" style="position:absolute;top:128px;left:722px;width:260px;"><b><u><font color="white">Submitted Shifts:</font></u></b>
    
    <br>
    
    <i>You have not submitted any shifts in this session.</i>
    </div>
    
    </body>
    Helping to build a bigger box. - Adam Matthews

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,047
    Thanks
    0
    Thanked 251 Times in 247 Posts
    try:

    window.pane.location.href = window.pane.location.pathname + "#" + URL;


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •