JP128 Posted June 17, 2006 Share Posted June 17, 2006 <?phpif($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 Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/ Share on other sites More sharing options...
JP128 Posted June 17, 2006 Author Share Posted June 17, 2006 Do you know what i mean? Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46688 Share on other sites More sharing options...
.josh Posted June 17, 2006 Share Posted June 17, 2006 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) [snapback]384993[/snapback][/div][div class=\'quotemain\'][!--quotec--]<?phpif($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] Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46729 Share on other sites More sharing options...
JP128 Posted June 17, 2006 Author Share Posted June 17, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46756 Share on other sites More sharing options...
redarrow Posted June 17, 2006 Share Posted June 17, 2006 editor.php?&filename=<?php echo $file; ?> Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46764 Share on other sites More sharing options...
klaroen Posted June 17, 2006 Share Posted June 17, 2006 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()'> Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46768 Share on other sites More sharing options...
Fyorl Posted June 17, 2006 Share Posted June 17, 2006 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) Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46799 Share on other sites More sharing options...
poirot Posted June 17, 2006 Share Posted June 17, 2006 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 Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46801 Share on other sites More sharing options...
Fyorl Posted June 17, 2006 Share Posted June 17, 2006 [!--quoteo(post=385114:date=Jun 17 2006, 05:11 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 17 2006, 05:11 PM) [snapback]385114[/snapback][/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. Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46803 Share on other sites More sharing options...
JP128 Posted June 17, 2006 Author Share Posted June 17, 2006 ok, let me try that Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46806 Share on other sites More sharing options...
JP128 Posted June 17, 2006 Author Share Posted June 17, 2006 hmm, it isnt working still. Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46845 Share on other sites More sharing options...
trq Posted June 17, 2006 Share Posted June 17, 2006 Read the link in my signiture. Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46847 Share on other sites More sharing options...
JP128 Posted June 18, 2006 Author Share Posted June 18, 2006 it says that it isnt defined... the editPopup Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46848 Share on other sites More sharing options...
Fyorl Posted June 18, 2006 Share Posted June 18, 2006 [!--quoteo(post=385158:date=Jun 17 2006, 06:51 PM:name=JP128)--][div class=\'quotetop\']QUOTE(JP128 @ Jun 17 2006, 06:51 PM) [snapback]385158[/snapback][/div][div class=\'quotemain\'][!--quotec--]hmm, it isnt working still.[/quote]Have you tried looking at it in the Javascript console yet? Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46849 Share on other sites More sharing options...
JP128 Posted June 18, 2006 Author Share Posted June 18, 2006 Yea, I am looking at the console, it said undefined, but I re-did the entire script and it works now, butnow it keeps going to one file... the last file in the directoryhere is the code.<?phpif($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);?> Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46850 Share on other sites More sharing options...
Fyorl Posted June 18, 2006 Share Posted June 18, 2006 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:[code]<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>";}[/code] 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. Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46851 Share on other sites More sharing options...
JP128 Posted June 18, 2006 Author Share Posted June 18, 2006 if I put it there, it makes it undefined Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46853 Share on other sites More sharing options...
Fyorl Posted June 18, 2006 Share Posted June 18, 2006 *sigh* You're not making this easy for me are you? What does your code look like now and what makes what undefined. Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46854 Share on other sites More sharing options...
JP128 Posted June 18, 2006 Author Share Posted June 18, 2006 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:<?phpif($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);?> Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46860 Share on other sites More sharing options...
Fyorl Posted June 18, 2006 Share Posted June 18, 2006 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46861 Share on other sites More sharing options...
JP128 Posted June 18, 2006 Author Share Posted June 18, 2006 YES! Thank you so much! Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46866 Share on other sites More sharing options...
Fyorl Posted June 18, 2006 Share Posted June 18, 2006 You're welcome Quote Link to comment https://forums.phpfreaks.com/topic/12244-php-with-a-bit-of-javascript/#findComment-46867 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.