Jump to content

[SOLVED] Changing A Forms Action


pleek

Recommended Posts

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>';

?>

Link to comment
Share on other sites

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>';

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.