pleek Posted December 21, 2008 Share Posted December 21, 2008 ok so i have a working html script that changes the action of the form on the page. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <HTML> <HEAD> <TITLE>Untitled</TITLE> <META NAME="GENERATOR" CONTENT="MAX's HTML Beauty++ 2004"> </HEAD> <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"> function changeAction() { document.myform.action = "upload.php?FN=3DWORLD"; } </SCRIPT> <BODY> <A HREF="javascript:changeAction()">change the action</A> <form name="myform" action="uploader.php" method="POST" enctype="multipart/form-data"> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" NAME="change" value="Upload File"> </form> </BODY> </HTML> But when i expanded it and changed to php it doesn't work anymore. Any clue y? I have looked over the script at least 15 times and i can't find anything wrong. <?php echo' <HTML> <HEAD> <TITLE>Form</TITLE> <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"> function DWORLD() { document.myform.action = "uploader.php?FN=3DWORLD"; } function 10yard() { document.myform.action = "uploader.php?FN=10yard"; } function 1942() { document.myform.action = "uploader.php?FN=1942"; } function 1943() { document.myform.action = "uploader.php?FN=1943"; } function 720() { document.myform.action = "uploader.php?FN=720"; } function 8eyes() { document.myform.action = "uploader.php?FN=8eyes"; } </SCRIPT> </HEAD> <BODY> <TABLE> <TR> <TD>'; if (file_exists('Games/10yard.NES')) { echo ''; }else{ echo '<A HREF="javascript:10yard()">10-Yard Fight</A><BR>'; } if (file_exists('Games/1942.NES')) { echo ''; }else{ echo '<A HREF="javascript:1942()">1942</A><BR>'; } if (file_exists('Games/1943.NES')) { echo ''; }else{ echo '<A HREF="javascript:1943()">1943</A><BR>'; } if (file_exists('Games/3DWORLD.NES')) { echo ''; }else{ echo '<A HREF="javascript:DWORLD()">3-D WorldRunner</A><BR>'; } if (file_exists('Games/720.NES')) { echo ''; }else{ echo '<A HREF="javascript:720()">720°</A><BR>'; } if (file_exists('Games/8eyes.NES')) { echo ''; }else{ echo '<A HREF="javascript:8eyes()">8 Eye\'s</A><BR>'; } echo' </TD> <TD> <form name="myform" action="uploader.php" method="POST" enctype="multipart/form-data"> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" NAME="change" value="Upload File"> </form> </TD> </TR> </TABLE> </BODY> </HTML>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/137948-solved-changing-a-forms-action/ Share on other sites More sharing options...
phpSensei Posted December 22, 2008 Share Posted December 22, 2008 Wheres the top part in the php script? Nothing seems to be wrong with php... Quote Link to comment https://forums.phpfreaks.com/topic/137948-solved-changing-a-forms-action/#findComment-721105 Share on other sites More sharing options...
sKunKbad Posted December 22, 2008 Share Posted December 22, 2008 I tried your original script (HTML) in FF and it doesn't change the action. Quote Link to comment https://forums.phpfreaks.com/topic/137948-solved-changing-a-forms-action/#findComment-721110 Share on other sites More sharing options...
sKunKbad Posted December 22, 2008 Share Posted December 22, 2008 The problem is that a javascript function name cannot start with a number: Try this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <?php echo' <HTML> <HEAD> <TITLE>Form</TITLE> <SCRIPT TYPE="text/javascript" LANGUAGE="JavaScript"> <!-- function DWORLD() { document.myform.action = "uploader.php?FN=3DWORLD"; } function TENyard() { document.myform.action = "uploader.php?FN=10yard"; } function NINETEEN42() { document.myform.action = "uploader.php?FN=1942"; } function NINETEEN43() { document.myform.action = "uploader.php?FN=1943"; } function SEVEN20() { document.myform.action = "uploader.php?FN=720"; } function EIGHTeyes() { document.myform.action = "uploader.php?FN=8eyes"; } --> </SCRIPT> </HEAD> <BODY> <TABLE> <TR> <TD>'; if (file_exists('Games/10yard.NES')) { echo ''; }else{ echo '<A HREF="javascript:TENyard()">10-Yard Fight</A><BR>'; } if (file_exists('Games/1942.NES')) { echo ''; }else{ echo '<A HREF="javascript:NINETEEN42()">1942</A><BR>'; } if (file_exists('Games/1943.NES')) { echo ''; }else{ echo '<A HREF="javascript:NINETEEN43()">1943</A><BR>'; } if (file_exists('Games/3DWORLD.NES')) { echo ''; }else{ echo '<A HREF="javascript:DWORLD()">3-D WorldRunner</A><BR>'; } if (file_exists('Games/720.NES')) { echo ''; }else{ echo '<A HREF="javascript:SEVEN20()">720°</A><BR>'; } if (file_exists('Games/8eyes.NES')) { echo ''; }else{ echo '<A HREF="javascript:EIGHTeyes()">8 Eye\'s</A><BR>'; } echo' </TD> <TD> <form name="myform" action="uploader.php" method="POST" enctype="multipart/form-data"> Choose a file to upload: <input name="uploadedfile" type="file" /><br /> <input type="submit" NAME="change" value="Upload File"> </form> </TD> </TR> </TABLE> </BODY> </HTML>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/137948-solved-changing-a-forms-action/#findComment-721115 Share on other sites More sharing options...
pleek Posted December 22, 2008 Author Share Posted December 22, 2008 ah, ok. i have to go right now but ill try that tomorrow and check. Thanks a lot man! Quote Link to comment https://forums.phpfreaks.com/topic/137948-solved-changing-a-forms-action/#findComment-721117 Share on other sites More sharing options...
pleek Posted December 22, 2008 Author Share Posted December 22, 2008 your script works, thanks for pointing out my error. Quote Link to comment https://forums.phpfreaks.com/topic/137948-solved-changing-a-forms-action/#findComment-721513 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.