Jump to content

Any good programmer here !!


icefire

Recommended Posts

Hi!

my website is about a html code that extract a code in one iframe "iframe1" and execute the result in onther iframe "iframe2"

In the first i had an iframe box that my txt files excute in :

my iframe code :

<iframe name="iframe1" width="320" height="320" src="" frameborder="yes" scrolling="yes"> </iframe>

 

and this is my txt files page:

<div>
<ul>
<li><a href="file01.txt" name = "file01.txt" target="iframe1">Getting started </a><a href="file01.html" target="iframe2">(file01)</a></li>
<li><a href="file02.txt" name = "file02.txt" target="iframe1">Getting started </a><a href="file02.html" target="iframe2">(file02)</a></li>
<li><a href="file03.txt" name = "file03.txt" target="iframe1">Getting started </a><a href="file03.html" target="iframe2">(file03)</a></li>
</ul>
</div>

 

and its work perfectly.  :)

 

Then i changed my iframe1 to a textarea box to let the user to modify the code a"txtfile". But now i cant extract the code a"txt file" in a textarea like when i was extracted in iframe

 

my textarea code:

<form action="showcode.php" method="post" name="form" target="iframe2">
<textarea name="textareaa" cols="32" rows="16">
</textarea>
<input type="submit" value="Save" />
</form>

 

showcode.php

<?php
$test=$_POST['textareaa'];
echo($test);
?>

 

i tried to modify the target of my txt files from "iframe1"  to "textareaa"

<div>
<ul>
<li><a href="file01.txt" name = "file01.txt" target="textareaa">Getting started </a><a href="file01.html" target="iframe2">(file01)</a></li>
<li><a href="file02.txt" name = "file02.txt" target="textareaa">Getting started </a><a href="file02.html" target="iframe2">(file02)</a></li>
<li><a href="file03.txt" name = "file03.txt" target="textareaa">Getting started </a><a href="file03.html" target="iframe2">(file03)</a></li>
</ul>
</div>

 

but its not work..  :-\

its open the txt file in a new page not in the textarea box    >:(

 

SO any good programmer can SOLVE my problem ??

 

 

Link to comment
Share on other sites

You can't do this with a server side language... it would require a reload of the page. Because php is server side program you can't modify without a submit button, link, ect... resulting in a reload of the page even if you call the results back to the page. This can be done, but I doubt how you want since when you reload the text area with a server side program like php the page containing the text area has to reload. You were able to do this with iframes because what was in the iframe was another open page, so it reloaded without reloading the page the iframe was contained in. With that said... what exactly do you want to do? This is very quickly done with a javascript but you don't want to use that so one of three options... use it the way you did with iframes... Use Javascript... or deal with page reloading.

Link to comment
Share on other sites

just for you though, here is a php example of how to do something similar.  you'll have to edit it to fit your own needs.

 

<?

if($_POST['Submit']){

$open = fopen("textfile.txt","w+");

$text = $_POST['update'];

fwrite($open, $text);

fclose($open);

echo "File updated.<br />";

echo "File:<br />";

$file = file("textfile.txt");

foreach($file as $text) {

echo $text."<br />";

}

}else{

$file = file("textfile.txt");

echo "<form action=\"".$PHP_SELF."\" method=\"post\">";

echo "<textarea Name=\"update\" cols=\"50\" rows=\"10\">";

foreach($file as $text) {

echo $text;

}

echo "</textarea>";

echo "<input name=\"Submit\" type=\"submit\" value=\"Update\" />\n

</form>";

}

?>

 

 

guess where i found it? google!

Link to comment
Share on other sites

well of course.  while i would prefer him to use some javascript for the functionality, ease of getting it done and what not.  if he doesnt want to, figured i'd google what he wants and find the less then preferable way of doing it, especially if the text file gets to be gigantic.

 

hell some OOP php, combined with smarty, ajax with jquery -- thats the way i'd do it ;D

Link to comment
Share on other sites

:o

well..

this is my assignement at collage in php course  :P

the Assignement is  "Modify the above application so that the code block is displayed in a textbox to allow editing the script and insert/modify the code, save it and display t in the right block. Figure below shows the look of the main web page."

Link to comment
Share on other sites

Then reloading is ok, just ugly for real world applications is all.

Then it's a simple submit with the form calling itself.

For future reference... use these sites too www.php.net www.w3schools.com/php ... and when stuck ask us questions.

 

hell some OOP php, combined with smarty, ajax with jquery -- thats the way i'd do it ;D

 

You can keep smarty but otherwise I agree... I do as much as I can with PHP then insert javascript to make it user friendly or "pretty"

Link to comment
Share on other sites

Well if you are a JS are you an ajax guy too? i have some ajax ive been working on, it used to work now it doesnt work in IE8 but i fixed that, though now it doesnt work in any other browser lol.

Link to comment
Share on other sites

Well, that is an odd one... 

 

in IE8, i had to add return false after my onclick otherwise it read the href and redirected to index.php every time.

 

in firefox, the ajax runs but the page doesnt get queried it seems as it doesnt display...

 

with my link like:

<li><a href="index.php" onClick="changeNavigation('index.php', 'pages');"><span>Pages</span></a></li>

 

and my JS/Ajax function like:

 

/* Changing Navigation Function Starts ------------------------------*/

function changeNavigation(url, query) {
req=AjaxObjectCreateGeneral(); 
	if(req) { 
		var myRand = parseInt(Math.random()*99999999);
		var query = query;
		var url = url;
		var srcs = url+"?pg="+query+"&rand="+myRand;
		$('TransMsgDisplay').innerHTML='<img src="../templates/admin/img/indicator.gif" align="center">';
		req.onreadystatechange = processNavigation;
		req.open("GET",srcs,false);
		req.send(null);
	} 
}

function processNavigation()
{
if(req.readyState == 4) 
{
	if(req.status == 200) 
	{  
		$('TransMsgDisplay').innerHTML=req.responseText;
	}
}

}


/*-------------------Changing Navigation Function Ends ------------------*/

 

having issues wrapping my head around it.  thing is, i could use javascript: void(0) or #, but one of the pages i cant query using ajax (that ive found a way to do it) as ive got scriptaculous dragdrop to create the dynamic menu building for the front end in there so if i used either one of those @ some point my address bar would constantly show index.php?pg=menus which isnt an issue, just looks horrible to me lol

 

 

Link to comment
Share on other sites

my assigment is almost finished i ll lose 1 mark for this trick  :P

 

i solve a lot of my assigments from this forum

 

bye ;)

And then you're going to take the job from somebody simply because you have the diploma, which in fact you never earned your self.  There is zero effort level in the new generation of kids.  The motto seems to be, "How can I get by doing as little as I possibly can?".
Link to comment
Share on other sites

my assigment is almost finished i ll lose 1 mark for this trick  :P

 

i solve a lot of my assigments from this forum

 

bye ;)

And then you're going to take the job from somebody simply because you have the diploma, which in fact you never earned your self.  There is zero effort level in the new generation of kids.  The motto seems to be, "How can I get by doing as little as I possibly can?".

 

ahaha... very true. In any case, its up to them to prove themselves when they actually get the job, unless they plan to put up a business instead of working for someone else.

Link to comment
Share on other sites

my assigment is almost finished i ll lose 1 mark for this trick  :P

 

i solve a lot of my assigments from this forum

 

bye ;)

And then you're going to take the job from somebody simply because you have the diploma, which in fact you never earned your self.  There is zero effort level in the new generation of kids.  The motto seems to be, "How can I get by doing as little as I possibly can?".

 

ahaha... very true. In any case, its up to them to prove themselves when they actually get the job, unless they plan to put up a business instead of working for someone else.

 

i just come to this forum for hard tricks i make this forum is my last way to solution.

for example this part of assingmnet is extremly hard Nobody can solve it even you   :P

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.