Jump to content


Photo

PHP with a bit of Javascript.


  • Please log in to reply
21 replies to this topic

#1 JP128

JP128
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationWisconsin

Posted 17 June 2006 - 03:22 PM

<?php
if($path = 1){
$file=$_GET['file'];
$path = "../htdocs/$file";
}else {
$path = "../htdocs/";
}
$i = 0;
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
$i = $i + 1;
?>
<script language="text/javascript">
function editPopup(){
window.open('/editor.php?filename=$file', "myWindow", "status=1, height=550, width=850, resizable=0");
</script>
<?php
echo "<form method='get' action='/editor.php?filename=$file'>$i: <input type=text name='filename' value='$file'> <input type='submit' value='EDIT' onClick='editPopup()'></form><br>";

}
closedir($dh);
?>

I need this to work. What it is supposed to do is let the user click on a button, the EDIT on, and then have a pop up window show up... but this is not working...! Dont worry about the top stuff, just basically the javascript, and the form. I need help to get those two to work together.


thanks
-----------------------------------------------------------------------
John Ensign - Age 16 - PHP Learner

My email is Johnny.Ensign@gmail.com

#2 JP128

JP128
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationWisconsin

Posted 17 June 2006 - 03:42 PM

Do you know what i mean?
-----------------------------------------------------------------------
John Ensign - Age 16 - PHP Learner

My email is Johnny.Ensign@gmail.com

#3 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 17 June 2006 - 06:34 PM

no i don't really know what you mean but here's a couple things you need to fix. they may or may not fix your problem i don't know cuz i don't know what you mean. even though these things i pointed out are php related, it sounds to me like you need to be asking this in the javascript section anyways.
[!--quoteo(post=384993:date=Jun 17 2006, 10:22 AM:name=JP128)--][div class=\'quotetop\']QUOTE(JP128 @ Jun 17 2006, 10:22 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
<?php
if($path [!--coloro:red--][span style=\"color:red\"][!--/coloro--]==[!--colorc--][/span][!--/colorc--] 1){
$file=$_GET['file'];
$path = "../htdocs/$file";
}else {
$path = "../htdocs/";
}
$i = 0;
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
$i = $i + 1;
?>
<script language="text/javascript">
function editPopup(){
window.open('/editor.php?filename=[!--coloro:red--][span style=\"color:red\"][!--/coloro--]<?= $file ?>[!--colorc--][/span][!--/colorc--]', "myWindow", "status=1, height=550, width=850, resizable=0");
</script>
<?php
echo "<form method='get' action='/editor.php?filename=$file'>$i: <input type=text name='filename' value='$file'> <input type='submit' value='EDIT' onClick='editPopup()'></form><br>";

}
closedir($dh);
?>

I need this to work. What it is supposed to do is let the user click on a button, the EDIT on, and then have a pop up window show up... but this is not working...! Dont worry about the top stuff, just basically the javascript, and the form. I need help to get those two to work together.
thanks
[/quote]
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#4 JP128

JP128
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationWisconsin

Posted 17 June 2006 - 07:43 PM

I am trying to get a window to pop up. I want the file to pop up when the "EDIT" button is pressed. The url of the popup should be

editor.php?filename=<?php echo $file; ?>

That link works, but it doesnt open the window.
-----------------------------------------------------------------------
John Ensign - Age 16 - PHP Learner

My email is Johnny.Ensign@gmail.com

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 17 June 2006 - 08:00 PM

editor.php?&filename=<?php echo $file; ?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 klaroen

klaroen
  • Members
  • PipPipPip
  • Advanced Member
  • 34 posts

Posted 17 June 2006 - 08:10 PM

here is something:

You don't need a form I think... just a button than does the onlclick thing:

<input type='button' value='EDIT' onClick='editPopup()'>

#7 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 17 June 2006 - 10:08 PM

Run it in Firefox and open the Javascript console to see what error's are popping up (or get the FireBird extension which is better than the Javascript console)
[table]



Don't worry, the printer fairies will sort it out.

#8 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 17 June 2006 - 10:11 PM

You can't just change the submit button to do that.

If you want the form to be submit to a new window, specify a different target for the form element.

800th post! [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
~ D Kuang

#9 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 17 June 2006 - 10:16 PM

[!--quoteo(post=385114:date=Jun 17 2006, 05:11 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 17 2006, 05:11 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You can't just change the submit button to do that.

If you want the form to be submit to a new window, specify a different target for the form element.

800th post! [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /]
[/quote]

You just reminded me...
If you don't need any data apart from the filename to appear in the popup then you don't need the action on the form and can just change the button's type from submit to button. However, to find the real problem, I would still recommend Firefox's Javascript Console.
[table]



Don't worry, the printer fairies will sort it out.

#10 JP128

JP128
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationWisconsin

Posted 17 June 2006 - 10:23 PM

ok, let me try that

-----------------------------------------------------------------------
John Ensign - Age 16 - PHP Learner

My email is Johnny.Ensign@gmail.com

#11 JP128

JP128
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationWisconsin

Posted 17 June 2006 - 11:51 PM

hmm, it isnt working still.


-----------------------------------------------------------------------
John Ensign - Age 16 - PHP Learner

My email is Johnny.Ensign@gmail.com

#12 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 17 June 2006 - 11:56 PM

Read the link in my signiture.

#13 JP128

JP128
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationWisconsin

Posted 18 June 2006 - 12:00 AM

it says that it isnt defined... the editPopup
-----------------------------------------------------------------------
John Ensign - Age 16 - PHP Learner

My email is Johnny.Ensign@gmail.com

#14 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 18 June 2006 - 12:00 AM

[!--quoteo(post=385158:date=Jun 17 2006, 06:51 PM:name=JP128)--][div class=\'quotetop\']QUOTE(JP128 @ Jun 17 2006, 06:51 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
hmm, it isnt working still.
[/quote]

Have you tried looking at it in the Javascript console yet?
[table]



Don't worry, the printer fairies will sort it out.

#15 JP128

JP128
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationWisconsin

Posted 18 June 2006 - 12:07 AM

Yea, I am looking at the console, it said undefined, but I re-did the entire script and it works now, but
now it keeps going to one file... the last file in the directory
here is the code.


<?php
if($path == 1){
$file=$_GET['file'];
$path = "../htdocs/$file";
}else {
$path = "../htdocs/";
}
$i = 0;
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
$i = $i + 1;
?>
<script language="JavaScript1.2">
function openwindow()
{
window.open("/editor.php?filename=<?php echo $file; ?>", "mywindow", "menubar=0,resizable=0,width=850,height=550,location=1");
}
</SCRIPT>
<?php
echo "<input type=text name='filename' value='$file'> <input type='submit' value='EDIT' onClick='openwindow()'><br>";

}
closedir($dh);
?>
-----------------------------------------------------------------------
John Ensign - Age 16 - PHP Learner

My email is Johnny.Ensign@gmail.com

#16 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 18 June 2006 - 12:13 AM

The problem is you're looping through a function declaration. So only the last function is ever used. What you need is to declare the function somewhere separate and have the file passed to it. For instance:
<script type="text/javascript">
function openwindow(filename)
{
window.open("editor.php?filename="+filename, "mywindow", "menubar=0,resizable=0,width=850,height=550,location=1");
}
</SCRIPT>

while (($file = readdir($dh)) !== false) {
if($file == '.' || $file == '..')
{
continue;
}
echo "<input type='button' value='EDIT' onClick=\"openwindow('$file')\"><br>";
}
Notice I removed the / at the beginning of editor.php as that would have pointed to a file in your base directory. Also, it's now openwindow($file) to work with the function.
[table]



Don't worry, the printer fairies will sort it out.

#17 JP128

JP128
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationWisconsin

Posted 18 June 2006 - 12:20 AM

if I put it there, it makes it undefined
-----------------------------------------------------------------------
John Ensign - Age 16 - PHP Learner

My email is Johnny.Ensign@gmail.com

#18 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 18 June 2006 - 12:21 AM

*sigh* You're not making this easy for me are you? What does your code look like now and what makes what undefined.
[table]



Don't worry, the printer fairies will sort it out.

#19 JP128

JP128
  • Members
  • PipPipPip
  • Advanced Member
  • 233 posts
  • LocationWisconsin

Posted 18 June 2006 - 12:57 AM

lol, I wish I could make it easy for you, or anyone. When I put it there, before the loop, nothing happens. Then I take a look at the console and it says that it is undefined.

Do you have AIM/MSN/or Yahoo!?
It would be faster to talk...



code:




<?php
if($path == 1){
$file=$_GET['file'];
$path = "../htdocs/$file";
}else {
$path = "../htdocs/";
}
$i = 0;
?>
<script language=\"JavaScript1.2\">
function openwindow()
{
window.open("editor.php?filename=$file", "mywindow", "menubar=0,resizable=0,width=850,height=550,location=1");
}
</SCRIPT>
<?php
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
$i = $i + 1;

echo "<input type=text name='filename' value='$file'> <input type='submit' value='EDIT' onClick='openwindow()'><br>";

}
closedir($dh);
?>
-----------------------------------------------------------------------
John Ensign - Age 16 - PHP Learner

My email is Johnny.Ensign@gmail.com

#20 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 18 June 2006 - 01:03 AM

My profile contains my MSN and AIM(which I never use) information if you want it but I'm pretty sure your problem is that you missed:

<script type="text/javascript">
function openwindow([!--coloro:red--][span style=\"color:red\"][!--/coloro--]filename[!--colorc--][/span][!--/colorc--])
{
window.open("editor.php?filename="[!--coloro:red--][span style=\"color:red\"][!--/coloro--]+filename[!--colorc--][/span][!--/colorc--], "mywindow", "menubar=0,resizable=0,width=850,height=550,location=1");
}
</script>

and further on...

echo "<input type=text name='filename' value='$file'> <input type='submit' value='EDIT' onClick=\"openwindow([!--coloro:red--][span style=\"color:red\"][!--/coloro--]'$file'[!--colorc--][/span][!--/colorc--])\"><br>";
[table]



Don't worry, the printer fairies will sort it out.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users