Hello
I have a simple requirement, I have a list of URLs on a page, I want that when the user clicks on any one URL, then a text box on the same page is filled with some data. The data to be filled in is specific for each URL.
Regards
Arvind
Hello
I have a simple requirement, I have a list of URLs on a page, I want that when the user clicks on any one URL, then a text box on the same page is filled with some data. The data to be filled in is specific for each URL.
Regards
Arvind
Jump to Posti think you want something like this :
htmlpage.htm :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="
Try this code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title>Populating text field</title>
<script type="text/javascript">
<!--
function textFill(ref, data) {
var ua = (document.all) ? document.all[ref] : document.layers[ref];
try {
if ( ua ) {
ua.value = data; }
else if ( !ua ) {
myForm.ref.value = data; }
else { document.getElementById(ref).value = data; } } catch(e) { alert("There is a problem on this code!"); } }
//-->
</script>
</head>
<body>
<div>
<form id="myForm" action="#" onsubmit="return false;">
<div>
<label>Field 1:</label><input type="text" id="txt1" name="txt1" value="" size="30" maxlength="30"><br>
<label>Field 2:</label><input type="text" id="txt2" name="txt2" value="" size="30" maxlength="30">
</div>
<p><a href="javascript:void(0);" onclick="textFill('txt1','This data goes to field 1');">Populate field 1</a><br>
<a href="javascript:void(0);" onclick="textFill('txt2','This data goes to field 2');">Populate field 2</a></p>
</form>
</div>
</body>
</html>
i think you want something like this :
htmlpage.htm :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<input type="text" id="someID" />
<br />
<a href="#" onclick="document.getElementById('someID').value='link1';">link1</a><br />
<a href="#" onclick="document.getElementById('someID').value='link2';">link2</a>
</body>
</html>
Thanks Serkan,
You have provided just what I was looking for
Regards
Arvind
What if I wanted to fill in the current date when that link was clicked? How would that code look?
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.