Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Only 1 generator works?
Old 05-18-2009, 12:32 PM Only 1 generator works?
Physicsguy's Avatar
404 - Title not found

Latest Blog Post:
Challenges
Posts: 824
Name: Scott
Location: Ontario
Trades: 0
Back in this thread, I posted a generator that made something you put in. I tried adding another generator to the same page the other is on on my site, but it doesn't work.

For example, here's what I have:

Code:
<fieldset>
<a name="hsggenerator"></a>
<h1>HSG</h1>
<em>Head Section Generator</em>


<script type="text/javascript">

/***********************************************
* Javascript Generator Script by PGReviews (Physicsguy's Reviews)
* Visit http://www.execulink.com/~kayes/physicsguy/web/ for reviews, guitar tablature, and more!
* This notice must stay intact for legal use
***********************************************/

function welcome()

  {
  document.write("<fieldset><b>HSG output:</b> <br><hr><br>  &lt;!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"  <br>  \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\"&gt;  <br>  &lt;html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\"&gt;  <br>  &lt;head&gt;  <br>  &lt;title&gt;" + document.forms["generatorform"]["nameofsite"].value + "&lt;/title&gt;  <br>  &lt;meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\" /&gt;  <br>  &lt;meta name=\"author\" content=\"" + document.forms["generatorform"]["nameofauthor"].value + "\" /&gt;  <br>  &lt;meta name=\"description\" content=\"" + document.forms["generatorform"]["descriptionofsite"].value + "\" /&gt;  <br>  &lt;meta name=\"keywords\" content=\"" + document.forms["generatorform"]["keywords"].value + "\" /&gt;  <br>  &lt;link rel=\"stylesheet\" href=\"" + document.forms["generatorform"]["stylesheet"].value + "\" type=\"text/css\" media=\"screen\" /&gt;  <br>  &lt;link rel=\"shortcut icon\" href=\"images/favicon.ico\" type=\"image/x-icon\"&gt;  <br>  &lt;/head&gt;  <br><br><hr></fieldset>");                                                                                                                  
  }

</script>

<p>Enter the name of your site:</p>

<form name="generatorform" action="generator.htm" onSubmit="welcome()">
<input type="text" name="nameofsite" size="20">
<br>
<p>Enter your name:</p>
<input type="text" name="nameofauthor" size="20">
<br>
<p>Enter the description of your site:</p>
<input type="text" name="descriptionofsite" size="80">
<p>Enter keywords for your site (seperate with commas):</p>
<input type="text" name="keywords" size="80">
<p>Enter the path to your stylesheet (if you have one, if not, don't even use this line, take it out):</p>
<input type="text" name="stylesheet" size="20">
<br><br>
<input type="submit" value="Code!">
</form>

<p>If you don't have a favicon (a favicon is the little picture you see beside the URL.) 
then just take out the 2 lines that say:  
<br> 
&lt;link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon"&gt;  
<br>  
&lt;link rel="icon" href="images/favicon.ico" type="image/x-icons"&gt;</p>
</fieldset>

<br /><br />


<fieldset>
<a name="websitegenerator"></a>
<h1>Website Generator</h1>
<em>Generates the part of the website in the &lt;body&gt; tags.</em>


<script type="text/javascript">

/***********************************************
* Javascript Generator Script by PGReviews (Physicsguy's Reviews)
* Visit http://www.execulink.com/~kayes/physicsguy/web/ for reviews, guitar tablature, and more!
* This notice must stay intact for legal use
***********************************************/

function welcome2()

  {
  document.write("&lt;h1&gt;" + document.forms["websitegenerator"]["headertitle"].value + "&lt;/h1&gt;);                                                                                                                  
  }

</script>

<p>Enter what you want the header to say:</p>
<form name="websitegenerator" action="generator.htm" onSubmit="welcome2()">
<input type="text" name="headertitle" size="20">
<input type="submit" value="Code!">
</form>
</fieldset>
You see, I've changed all the names of the forms and all, but I'm sort of a Javan00b, so I don't know what's going on. Whenever I thpe in what I want as my header (the 2nd generator) it outputs the 1st generator with nothing filled in. Here's the fautly script in action. Why doesn't this work?
__________________
Check out my
Please login or register to view this content. Registration is FREE

Last edited by Physicsguy; 05-18-2009 at 12:36 PM..
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-18-2009, 07:39 PM Re: Only 1 generator works?
Novice Talker

Posts: 13
Trades: 0
Use button instead of submit and use onClick event instead of onSubmit.

Code:
function welcome2()

  {
  document.write("&lt;h1&gt;" + document.forms["websitegenerator"]["headertitle"].value + "&lt;/h1&gt;");                         

                                                                                        
  }

</script>

<p>Enter what you want the header to say:</p>
<form name="websitegenerator">
<input type="text" name="headertitle" size="20">
<input type="button" value="Code!" onClick="welcome2()">
</form>
__________________
My ITwiw profile:
Please login or register to view this content. Registration is FREE

You can use your
Please login or register to view this content. Registration is FREE
profile as a virtual name card anywhere on the web.
itwiw is offline
Reply With Quote
View Public Profile
 
Old 05-19-2009, 05:34 PM Re: Only 1 generator works?
Physicsguy's Avatar
404 - Title not found

Latest Blog Post:
Challenges
Posts: 824
Name: Scott
Location: Ontario
Trades: 0
So I use
Code:
<input type="button" value="Code!" onClick="welcome2()">
instead of

Code:
<input type="submit" value="Code!">
for both?

I just change welcome2 to welcome to correspond.

Thank you so much!
__________________
Check out my
Please login or register to view this content. Registration is FREE
Physicsguy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Only 1 generator works?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11491 seconds with 12 queries