Form Scripting problem, help please!

Anything else. Post a funny site or tell us about yourself. Discuss current events or whatever else you want. Post off topic threads here.
Post Reply
User avatar
poehalcho
Elite Member
Posts: 6131
Joined: Mon Apr 30, 2007 3:32 pm
Quick Reply: Yes
Location: ┌(╬ಠ益ಠ)╯( ̄ー ̄)(ノ◕ヮ◕)ノ:・✧(╯°Д°)╯彡┻━┻ψ(`∇´)ψ(☞゚∀゚)☞¯\_(ツ)_/¯ლ(ಥ益ಥლ)ԅ༼ ◔ڡ◔༽งヽ༼ʘ̚ل͜ʘ̚༽ノᕕ(ᐛ)ᕗ( ͡° ͜ʖ ͡°)

Form Scripting problem, help please!

Post by poehalcho »

ok, this is the final part i need to have for my site.
i can't get it to check whether the form has been filled in or not...


Code:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>
<body> <script type="text/javascript">
function testform()
{
if(document.forms[0].elements[0].value==""
|| document.forms[0].elements[1].value=="none"
|| document.forms[0].elements[2].value==""
|| document.forms[0].elements[3].value==""
|| document.forms[0].elements[4].value=="")
  {
   alert("You must fill in all the information in this form")
   }
}
</SCRIPT>


<form>
<tr>
  <td>Please enter your Name</td><br>
  <td><input type="text" name="Name" size="50" maxlength="35" /></td>
</tr>
<br><br>
<tr>
  <td>What is your age?</td><br>
  <td>
   <select name="age">
    <option>none</option
    <option>5 </option>
    <option>6 </option>
    <option>7 </option>
    <option>8 </option>
    <option>9 </option>
   <option>10 </option>
    <option>11 </option>
   <option>12</option>
   <option>13</option>
   <option>14</option>
    <option>15 </option>
    <option>16 </option>
    <option>17 </option>
    <option>18 </option>
    <option>19 </option>
    <option>20 </option>
    <option>older than 20 </option>
    </select>
</td>
</tr>
<br><br>
<tr>
  <td valign="top">What is your favorite Character</td><br>
  <td>
   <input type="radio" name="character" value="Sonic" />Sonic
    <input type="radio" name="character" value="Knuckles" />Knuckles
    <input type="radio" name="character" value="Tails" />Tails
    <input type="radio" name="character" value="Shadow" />Shadow
    <input type="radio" name="character" value="Rouge" />Rouge
    <input type="radio" name="character" value="Eggman" />Eggman
    <input type="radio" name="character" value="Omega" />Omega
    <input type="radio" name="character" value="Metal" />Metal

  </td>
</tr>
<br><br>

<tr>
  <td valign="top">What are your favorite games?</td><br>
  <td>
   <input type="checkbox" name="game" value="Sonic 2D games" />Sonic 2D games<br />
   
    <input type="checkbox" name="game" value="Sonic Adventure 1" />Sonic Adventure 1<br />
    <input type="checkbox" name="game" value="Sonic Adventure 2" />Sonic Adventure 2<br />
      <input type="checkbox" name="game" value="Sonic Heroes" />Sonic Heroes<br />
      <input type="checkbox" name="game" value="Sonic the hedgehog 2006" />Sonic the hedgehog 2006<br />
      <input type="checkbox" name="game" value="Shadow the Hedgehog" />Shadow the Hedgehog<br />
    <input type="checkbox" name="game" value="Sonic and the Secret Rings" />Sonic and the Secret Rings<br />
      <input type="checkbox" name="game" value="Sonic Unleashed" />Sonic Unleashed<br />
</td>
</tr>
<br>
<tr>
  <td><button type="reset">Reset</button></td>
   
   
  <td><INPUT TYPE="button" VALUE="send e-mail" onClick="self.location='mailto:SonicDX_Adventure@Hotmail.com';"></td>
   

   
   
   <form action=mailto:Sonicdx_adventure@hotmail.com method="Email" name="form"></script>
</tr>

</form>
</body>
</html>




if anyone can help, it is greatly appreciated, with this done i can finally rest a bit T__T

edit:
i got the basics fro this site
http://www.geocities.com/sunsetstrip/al ... .htm#sec23
Image
Day[9] wrote:"Tea is a lot like gold expansions - it helps you kill people."
- Day[9] Daily 337 -

User avatar
klokus
Active Member
Posts: 572
Joined: Sun Mar 11, 2007 8:05 pm
Quick Reply: Yes
Location: Hercules
Contact:

Re: Form Scripting problem, help please!

Post by klokus »

you must link your submit-button with your "check"-function (testform())
DJ_Ettem - [ExcalibuR * ZoomZoom] ~ Lvl 95 ~ Pure STR Secret-build
FeelThePain - [SquadBlack] ~ Lvl 71 ~ Rogue
--> Hercules
Dutch_Legend Union TaxiTool (v.1.1)
http://www.silkroadforums.com/viewtopic.php?f=2&t=104027

User avatar
poehalcho
Elite Member
Posts: 6131
Joined: Mon Apr 30, 2007 3:32 pm
Quick Reply: Yes
Location: ┌(╬ಠ益ಠ)╯( ̄ー ̄)(ノ◕ヮ◕)ノ:・✧(╯°Д°)╯彡┻━┻ψ(`∇´)ψ(☞゚∀゚)☞¯\_(ツ)_/¯ლ(ಥ益ಥლ)ԅ༼ ◔ڡ◔༽งヽ༼ʘ̚ل͜ʘ̚༽ノᕕ(ᐛ)ᕗ( ͡° ͜ʖ ͡°)

Re: Form Scripting problem, help please!

Post by poehalcho »

mind explaining how?
Image
Day[9] wrote:"Tea is a lot like gold expansions - it helps you kill people."
- Day[9] Daily 337 -

User avatar
klokus
Active Member
Posts: 572
Joined: Sun Mar 11, 2007 8:05 pm
Quick Reply: Yes
Location: Hercules
Contact:

Re: Form Scripting problem, help please!

Post by klokus »

I'm not really familiar with your language, but I can see that you didn't use your function (above) in the source from the onClick-event (button) (could also be the formaction thingy)
DJ_Ettem - [ExcalibuR * ZoomZoom] ~ Lvl 95 ~ Pure STR Secret-build
FeelThePain - [SquadBlack] ~ Lvl 71 ~ Rogue
--> Hercules
Dutch_Legend Union TaxiTool (v.1.1)
http://www.silkroadforums.com/viewtopic.php?f=2&t=104027

User avatar
NuclearSilo
Forum God
Posts: 8834
Joined: Mon Aug 21, 2006 12:00 pm
Quick Reply: Yes
Location: Age of Wushu

Re: Form Scripting problem, help please!

Post by NuclearSilo »

in function testform, add:

Code: Select all

else self.location='mailto:SonicDX_Adventure@Hotmail.com';


at the bottom:

Code: Select all

<td><INPUT TYPE="button" VALUE="send e-mail" onClick="testform();"></td>


there is an error, you open with a form and close with a script tag:

Code: Select all

<form action=mailto:Sonicdx_adventure@hotmail.com method="Email" name="form"></script>


All inputs should be put in form. The code above should be put at the top where starts the first form

The send button should be input type submit (if you want to send the data to other page, otherwise you don't need form tag)

forms[0] and elements[0] can be replaced by their name or id to easier to keep track:

Code: Select all

document.form.Name.value==""
Playing Age of Wushu, dota IMBA

User avatar
poehalcho
Elite Member
Posts: 6131
Joined: Mon Apr 30, 2007 3:32 pm
Quick Reply: Yes
Location: ┌(╬ಠ益ಠ)╯( ̄ー ̄)(ノ◕ヮ◕)ノ:・✧(╯°Д°)╯彡┻━┻ψ(`∇´)ψ(☞゚∀゚)☞¯\_(ツ)_/¯ლ(ಥ益ಥლ)ԅ༼ ◔ڡ◔༽งヽ༼ʘ̚ل͜ʘ̚༽ノᕕ(ᐛ)ᕗ( ͡° ͜ʖ ͡°)

Re: Form Scripting problem, help please!

Post by poehalcho »

well I got somewhere with the help of Vandango, but he's playing medieval now...

currently it notices everything. but when you make it submit it looks for page named after my email. help please...

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>
<body>
<script type="text/javascript">
function disp_alert()

{

if (form.name.value == "")
   
   {
          alert( "Please enter your name." );
            form.action = "form.htm"
   }

}


</script>
<form name="form" action="Sonicdx_adventure@hotmail.com" method="post" onsubmit ="return disp_alert();">
<tr>
  <td>Please enter your Name</td><br>
  <td><input type="text" name="name" size="50" maxlength="35" /></td>
</tr>
<br><br>
<tr>
  <td>What is your age?</td><br>
  <td>
   <select name="age">
    <option>5 </option>
    <option>6 </option>
    <option>7 </option>
    <option>8 </option>
    <option>9 </option>
   <option>10 </option>
    <option>11 </option>
   <option>12</option>
   <option>13</option>
   <option>14</option>
    <option>15 </option>
    <option>16 </option>
    <option>17 </option>
    <option>18 </option>
    <option>19 </option>
    <option>20 </option>
    <option>older than 20 </option>
    </select>
 </td>
</tr>
<br><br>
<tr>
  <td valign="top">What is your favorite Character</td><br>
  <td>
   <input type="radio" name="character" value="Sonic" checked="checked" />Sonic
    <input type="radio" name="character" value="Knuckles" />Knuckles
    <input type="radio" name="character" value="Tails" />Tails
    <input type="radio" name="character" value="Shadow" />Shadow
    <input type="radio" name="character" value="Rouge" />Rouge
    <input type="radio" name="character" value="Eggman" />Eggman
    <input type="radio" name="character" value="Omega" />Omega
    <input type="radio" name="character" value="Metal" />Metal

  </td>
</tr>
<br><br>

<tr>
  <td valign="top">What are your favorite games?</td><br>
  <td>
   <input type="checkbox" name="game" value="Sonic 2D games" />Sonic 2D games<br />
   
    <input type="checkbox" name="game" value="Sonic Adventure 1" />Sonic Adventure 1<br />
    <input type="checkbox" name="game" value="Sonic Adventure 2" />Sonic Adventure 2<br />
      <input type="checkbox" name="game" value="Sonic Heroes" />Sonic Heroes<br />
      <input type="checkbox" name="game" value="Sonic the hedgehog 2006" />Sonic the hedgehog 2006<br />
      <input type="checkbox" name="game" value="Shadow the Hedgehog" />Shadow the Hedgehog<br />
    <input type="checkbox" name="game" value="Sonic and the Secret Rings" />Sonic and the Secret Rings<br />
      <input type="checkbox" name="game" value="Sonic Unleashed" />Sonic Unleashed<br />
 </td>
</tr>
<br>
<tr>
  <td><button type="reset">Reset</button></td>
  <td><button type="submit">Send</button></td><form method="post" name="btnName" onClick ="disp_alert()">
</tr>

</form>
</body>
</html>
Image
Day[9] wrote:"Tea is a lot like gold expansions - it helps you kill people."
- Day[9] Daily 337 -

User avatar
NuclearSilo
Forum God
Posts: 8834
Joined: Mon Aug 21, 2006 12:00 pm
Quick Reply: Yes
Location: Age of Wushu

Re: Form Scripting problem, help please!

Post by NuclearSilo »

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
</head>
<body>
<script type="text/javascript">
function disp_alert()
{
        var name=document.getElementById("name").value;
        if (name=="") {
                alert("Enter name");
        }
        else {
                window.location="mailto:SonicDX_Adventure@Hotmail.com?subject=Test mail&cc=partenaire@antonio.net&bcc=avocat@antonio.net&body=Hi, how are you?%0D%0AYour name is : "+name;
        }
}
</script>
<form id="form">
<tr>
  <td>Please enter your Name</td><br>
  <td><input type="text" name="name" id="name" size="50" maxlength="35" /></td>
</tr>
<br><br>
<tr>
  <td>What is your age?</td><br>
  <td>
   <select name="age">
   <option>None</option>
    <option>5 </option>
    <option>6 </option>
    <option>7 </option>
    <option>8 </option>
    <option>9 </option>
   <option>10 </option>
    <option>11 </option>
   <option>12</option>
   <option>13</option>
   <option>14</option>
    <option>15 </option>
    <option>16 </option>
    <option>17 </option>
    <option>18 </option>
    <option>19 </option>
    <option>20 </option>
    <option>older than 20 </option>
    </select>
</td>
</tr>
<br><br>
<tr>
  <td valign="top">What is your favorite Character</td><br>
  <td>
   <input type="radio" name="character" value="Sonic" />Sonic
    <input type="radio" name="character" value="Knuckles" />Knuckles
    <input type="radio" name="character" value="Tails" />Tails
    <input type="radio" name="character" value="Shadow" />Shadow
    <input type="radio" name="character" value="Rouge" />Rouge
    <input type="radio" name="character" value="Eggman" />Eggman
    <input type="radio" name="character" value="Omega" />Omega
    <input type="radio" name="character" value="Metal" />Metal
    <input type="radio" name="character" value="Other" checked="checked"/>Other

  </td>
</tr>
<br><br>

<tr>
  <td valign="top">What are your favorite games?</td><br>
  <td>
   <input type="checkbox" name="game" value="Sonic 2D games" />Sonic 2D games<br />
   
    <input type="checkbox" name="game" value="Sonic Adventure 1" />Sonic Adventure 1<br />
    <input type="checkbox" name="game" value="Sonic Adventure 2" />Sonic Adventure 2<br />
      <input type="checkbox" name="game" value="Sonic Heroes" />Sonic Heroes<br />
      <input type="checkbox" name="game" value="Sonic the hedgehog 2006" />Sonic the hedgehog 2006<br />
      <input type="checkbox" name="game" value="Shadow the Hedgehog" />Shadow the Hedgehog<br />
    <input type="checkbox" name="game" value="Sonic and the Secret Rings" />Sonic and the Secret Rings<br />
      <input type="checkbox" name="game" value="Sonic Unleashed" />Sonic Unleashed<br />
</td>
</tr>
<br>
<tr>
  <td><button type="reset">Reset</button></td>
  <td><button type="button" onClick="disp_alert()">Send</button></td>
</tr>

</form>
</body>
</html>
Playing Age of Wushu, dota IMBA

User avatar
poehalcho
Elite Member
Posts: 6131
Joined: Mon Apr 30, 2007 3:32 pm
Quick Reply: Yes
Location: ┌(╬ಠ益ಠ)╯( ̄ー ̄)(ノ◕ヮ◕)ノ:・✧(╯°Д°)╯彡┻━┻ψ(`∇´)ψ(☞゚∀゚)☞¯\_(ツ)_/¯ლ(ಥ益ಥლ)ԅ༼ ◔ڡ◔༽งヽ༼ʘ̚ل͜ʘ̚༽ノᕕ(ᐛ)ᕗ( ͡° ͜ʖ ͡°)

Re: Form Scripting problem, help please!

Post by poehalcho »

let the picture talk.
Attachments
nuclearsiloskillz.JPG
nuclearsiloskillz.JPG (30.05 KiB) Viewed 718 times
Image
Day[9] wrote:"Tea is a lot like gold expansions - it helps you kill people."
- Day[9] Daily 337 -

Post Reply

Return to “Off Topic Lounge”