[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 737
  • Last Modified:

Set input value onclick

What is wrong with my code?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Demo</title>
</head>
<body>
<form onsubmit="insertMedia();return false;" action="#">
<input id="src" name="src" type="text" value="" onchange="switchType(this.value);generatePreview();" />
</form>
<div onclick="document.getElementById('src').obj.value = 'hello world'">click here</div>
</body>
</html>

Open in new window

0
hankknight
Asked:
hankknight
  • 2
1 Solution
 
erikTsomikSystem Architect, CF programmer Commented:
try this
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
      "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Demo</title>
</head>
<body>
<form onsubmit="insertMedia();return false;" action="#">
<input id="src" name="src" type="text" value="" onchange="switchType(this.value);generatePreview();" />
</form>
<div onclick="document.getElementById('src').value = 'hello world'">click here</div>
 
</body>
</html>

Open in new window

0
 
erikTsomikSystem Architect, CF programmer Commented:
thanks . That was an easy fix
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now