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
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How do I use sub/string to populate?

    When I browse a 'txt' file and click on upload, it appears in an iFrame below. How do I extract that values below and populate it in the blank spaces above?
    eg. (Apple instead of Q1; 31 instead of Fill in Value)

    I was told to use something like strings. Can someone please elaborate more?

    Image: http://img261.imageshack.us/img261/9841/populatelb9.jpg

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,893
    Thanks
    202
    Thanked 2,528 Times in 2,506 Posts
    You will need to post your mark-up and Javascript code.

    You have six fruits and only five input boxes - clarify, please.

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts
    This is the code.

    Code:
    <script language="JavaScript" type="text/javascript">
    <!--
    function uploadfile () {
    	loadOuter ( document.getElementById ( "browsefile" ).value );
    }
    var srcFrame;
    //External content into a layer
    function loadOuter(doc) {
     srcFrame = document.getElementById("hiddenContent");
     srcFrame.src = doc;
     // workaround for missing onLoad event in IFRAME for NN6
     if (!srcFrame.onload) {
      setTimeout("transferHTML()", 1000)
     }
    }
    
    function transferHTML(){
     srcContent='';
     if (srcFrame.contentDocument){
      srcContent=srcFrame.contentDocument.getElementsByTagName("BODY")[0].innerHTML;
     }
     else if (srcFrame.contentWindow){
      srcContent=srcFrame.contentWindow.document.body.innerHTML;
     }
     document.getElementById("outerDisplay").innerHTML = srcContent
    }
    
    
    var DocAry=new Array('Test.txt','Test2.txt');
    
    function SelectList(v){
     if (v>0){
      loadOuter(DocAry[v-1]);
     }
    }
    
    //-->
    </script>
    Code:
    <script type="text/javascript"> 
    function ShowInputs()
    {
    	var idx=document.getElementById ( "menu1" ).selectedIndex-1;	
    	var valuearray = new Array ();
    	var xaxisarray = new Array ();
    	var inputarray = new Array ();
    	var colorarray = new Array ();
    	var color2array = new Array ();
    	for (i=0;i<=idx;i++) {
    		var xaxisid = "axis"+i;
    		if ( document.getElementById ( xaxisid ) != null ) {
    			if ( document.getElementById ( xaxisid ).value != "" ) {
    				xaxisarray[i] = '<input type="text" id="axis'+i+'" size="3" value="'+document.getElementById ( xaxisid ).value+'" />';
                		}
    		} 
    		else {
    			xaxisarray[i] = '<input type="text" id="axis'+i+'" size="3" value="Q'+i+'" />';
    		}	
    		var colorid = "input_field_"+i;
    		if ( document.getElementById ( colorid ) != null ) {
    			if ( document.getElementById ( colorid ).value != "" ) {
    				colorarray[i] = '<input type="hidden" id="input_field_'+i+'" size="9" value="'+document.getElementById ( colorid ).value+'">';
    				color2array[i] = '<input type="text" disabled="true" id="sample_'+i+'" size="1" value="" style="background-color:'+document.getElementById ( colorid ).value+'" />';
                }
    		} 
    		else {
    			colorarray[i] = '<input type="hidden" id="input_field_'+i+'" size="9" value="#FFFFFF">';
    			color2array[i] = '<input type="text" disabled="true" id="sample_'+i+'" size="1" value="" style="background-color:#FFFFFF" />';
    		}	
    		var inputid = "input"+i;
    		if ( document.getElementById ( inputid ) != null ) {
    			if ( document.getElementById ( inputid ).value != "" ) {
    				inputarray[i] = '<input type="text" name="entry" onkeyup="valid(this)" id="input'+i+'" value="'+document.getElementById ( inputid ).value+'"/>';
                		}
    		} 
    		else {
    			if ( i == 0 || i == 1 || i == 2 )
    				inputarray[i] = '<input type="text" name="entry" onkeyup="valid(this)" id="input'+i+'" value="50"/>';
    			else
    				inputarray[i] = '<input type="text" name="entry" onkeyup="valid(this)" id="input'+i+'" value="Fill in value"/>';
    		}	
    	}
            // reset container content before adding inputs
           	document.getElementById('container').innerHTML = '';
    		
    	for (i=0;i<=idx;i++) {
    		document.getElementById('container').innerHTML += '<b>X-Axis</b>:<br>'+xaxisarray[i]+'&nbsp;&nbsp;&nbsp;&nbsp;';
    		document.getElementById('container').innerHTML += '<input type="button" onclick="showColorGrid2(\'input_field_'+i+'\',\'sample_'+i+'\');" value="Color">';
    		document.getElementById('container').innerHTML += '&nbsp;'+colorarray[i];
    		document.getElementById('container').innerHTML += '&nbsp;'+color2array[i];
    		document.getElementById('container').innerHTML += '&nbsp;'+inputarray[i]+'<br>';
    		document.getElementById('container').innerHTML += '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div id="colorpicker201" class="colorpicker201"></div>';
    	}
    }
    
    </script>
    You have six fruits and only five input boxes - clarify, please.
    That was just an example mate. So let say it's 6 fruits and 6 input boxes.

    Cheers for the reply.
    Last edited by ferrariboy21; 12-27-2008 at 02:20 PM.


  •  

    Posting Permissions

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