www.webdeveloper.com
Results 1 to 2 of 2

Thread: Insert data into textbox on clicking href link

  1. #1
    Join Date
    Oct 2011
    Posts
    16

    Insert data into textbox on clicking href link

    Dear all,

    I have executed a code in which I tried to insert data into textbox on clicking href link. However that could be done only for a textarea. I have mentioned the code below. Please help me out


    HTML Code:
    <head>
    	
    	<link rel="stylesheet" href="general.css" type="text/css" media="screen" />
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">
    
    $(document).ready(function(){
    
    
        $(".slidingDiv").hide();
    	$(".show_hide").show();
    	
    	$('.show_hide').click(function(){
    	$(".slidingDiv").slideToggle();
    	});
    });
    
    </script>
    	<script src="http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js" type="text/javascript"></script>
    	<style type="text/css">
    	a{
    		text-decoration:none;
    		font-family:arial;
    		font-size:14px;
    	}
    	p{
    		font-family:arial;
    		padding-left:5px;
    	}
    	#tree li{
    			list-style-type:none;
    			font-family: "Myriad Pro";
    			font-size:14px;
    		}
    		#topNodes{
    			margin-left:0px;
    			padding-left:0px;
    		}
    		#topNodes ul{
    			margin-left:20px;
    			padding-left:0px;
    			display:none;
    		}
    		#tree .tree_link{
    			line-height:13px;
    			padding-left:2px;
    
    		}
    		#tree img{
    			padding-top:2px;
    		}
    		#tree a{
    			color: #000000;
    			text-decoration:none;
    		}
    		.activeNodeLink{
    			background-color: #316AC5;
    			color: #FFFFFF;
    			font-weight:bold;
    		}
    		.slidingDiv {
    	/*background:url(images/slidingDiv.png) no-repeat;*/
    	padding-left: 600px;
    	padding-top: 100px;
    	height: 210px;
    	width: 100%;
    }
    
    .show_hide {
    	display:none;
    }
    	</style>
    </head>
    <body style="margin-top: 200px;">
    <script type="text/javascript">
    function insertText(val,e){
    document.getElementById(e).innerHTML = val;
    /*$('#popupContact').hide();
    */}
    
    </script>
    	<center>
    		<!--<a href="#" id="popup"><input type="button" value="Click here to open popup and view tree" /></a>-->
    		<a href="#" class="show_hide">View tree</a><span style="padding-left: 100px;"><textarea id="textIns" ></textarea></span>
    	</center>
    	<!--<div id="popupContact">
    		<a id="popupContactClose"><img src="close.png" /></a>-->
    		<!--<h1>Title of our cool popup, yay!</h1>-->
            <div class="slidingDiv">
            <a href="#" onclick="expandAll();return false">Expand all nodes</a><br><br />
        <a href="#" onclick="collapseAll();return false">Collapse all nodes</a><br><br />
    	<script type="text/javascript" src="tree.js"></script>
    	<div id="tree">
        	<ul id="topNodes">
            	<li class="tree_node" id="node_1"><img id="plusMinus1" class="tree_plusminus" src="images/plus.gif"><img src="images/folder.gif"><a class="tree_link">Arts & Entertainment</a><ul><li class="tree_node"><img class="tree_plusminus" id="plusMinus2" src="images/plus.gif"><img src="images/folder.gif"><a class="tree_link" href="#">Movies</a><ul><li class="tree_node"><img class="tree_plusminus" id="plusMinus3" src="images/plus.gif"><img src="images/sheet.gif"><a class="tree_link" href="javascript:insertText('Alabama','textIns');" onClick="void(0)">Alabama</a></li><li class="tree_node"><img class="tree_plusminus" id="plusMinus4" src="images/plus.gif"><img src="images/sheet.gif"><a class="tree_link" href="javascript:insertText('Alaska','textIns');" onClick="void(0)">Alaska</a></li><li class="tree_node"><img class="tree_plusminus" id="plusMinus7" src="images/plus.gif"><img src="images/folder.gif"><a class="tree_link">California</a><ul><li class="tree_node"><img class="tree_plusminus" id="plusMinus69" src="images/plus.gif"><img src="images/sheet.gif"><a class="tree_link" href="javascript:insertText('Los Angeles','textIns');" onClick="void(0)">Los Angeles</a></li></ul></li><li class="tree_node"><img class="tree_plusminus" id="plusMinus8" src="images/plus.gif"><img src="images/sheet.gif"><a class="tree_link" href="javascript:insertText('Colorado','textIns');" onClick="void(0)">Colorado</a></li></ul></li></ul></li><li class="tree_node" id="node_51"><img id="plusMinus51" class="tree_plusminus" src="images/plus.gif"><img src="images/folder.gif"><a class="tree_link">Europe</a><ul><li class="tree_node"><img class="tree_plusminus" id="plusMinus52" src="images/plus.gif"><img src="images/folder.gif"><a class="tree_link">Norway</a><ul><li class="tree_node"><img class="tree_plusminus" id="plusMinus57" src="images/plus.gif"><img src="images/sheet.gif"><a class="tree_link" href="javascript:insertText('Haugesund','textIns');" onClick="void(0)">Haugesund</a></li></ul></li><li class="tree_node"><img class="tree_plusminus" id="plusMinus58" src="images/plus.gif"><img src="images/folder.gif"><a class="tree_link">Sweden</a><ul><li class="tree_node"><img class="tree_plusminus" id="plusMinus59" src="images/plus.gif"><img src="images/sheet.gif"><a class="tree_link" href="javascript:insertText('Stockholm','textIns');" onClick="void(0)">Stockholm</a></li></ul></li><li class="tree_node"><img class="tree_plusminus" id="plusMinus60" src="images/plus.gif"><img src="images/folder.gif"><a class="tree_link">Denmark</a><ul><li class="tree_node"><img class="tree_plusminus" id="plusMinus61" src="images/plus.gif"><img src="images/sheet.gif"><a class="tree_link" href="javascript:insertText('Copenhagen','textIns');" onClick="void(0)">Copenhagen</a></li></ul></li></ul>
               </li>
          </ul>
    	</div></div>
        <br />
        
    	<!--</div>-->
    	<div id="backgroundPopup"></div>
    </body>

    Regards.

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,654
    use .value instead of .innerHTML

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles