1 Replies - 445 Views - Last Post: 15 September 2012 - 02:41 AM

#1 Dkaussie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 14-September 12

Code incorrect? Attempting to use javascript variables in HTML?

Posted 14 September 2012 - 05:56 PM

<script>
	var text1 = "Form1";
	var text2 = "Form2";
	var visibility1 = "visible";
	var visibility2 = "hidden";
	var value1 = 0;
	var value2 = 0;
</script>

<form id="mainForm" name="form" action="" method="get">
					<b><script language="Javascript">document.write(text1);</SCRIPT></b> <script language="Javascript">document.write('<input type="number" name="form1" id="Form1" min="0" value='+ value1 + 'style="visiblity:' + visibility1 + ';"/>');</script> <br />
					<b><script language="Javascript">document.write(text2);</SCRIPT></b> <script language="Javascript">document.write('<input type="number" name="form2" id="Form2" min="0" value='+ value2 + 'style="visiblity:' + visibility2 + ';"/>');</script>
					<center><input id="button" name="button" type="submit" value="Go!" onclick="start()" /></center>
				</form>

These are just samples of the code i am trying to write. Anyway I am trying to use javascript variables in HTML. So far it creates the text input but doesn't change it's visibility or value. Please help. Thanks

This post has been edited by Dormilich: 15 September 2012 - 02:39 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Code incorrect? Attempting to use javascript variables in HTML?

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3479
  • View blog
  • Posts: 10,023
  • Joined: 08-June 10

Re: Code incorrect? Attempting to use javascript variables in HTML?

Posted 15 September 2012 - 02:41 AM

you need a space before the style attribute.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1