jQuery Change Input text upon selection of radio button -
trying value="" of <input class="box" type="text" value="??" name="searchquery"
change upon selection of radio button. if user presses 'first name' radio button example, changes value of .box input value such "enter first name" , have other radio buttons well.
can help? jquery novice here :)
<!doctype html> <html> <head> <link rel="stylesheet" href="global.css" media="screen" /> <link rel="stylesheet" href="design.css" media="screen" /> <style type="text/css"> .hidden { display: none; } </style> <script type="text/javascript" src="inc/jquery.js"> </script> <script type="text/javascript">$(function() {$('input[type=text]').focus(function() {$(this).val('')});});</script> <!-- // --> **<script> $("#searchselect").change(function () { var str = ""; $("radio option:option1").each(function () { str += $(this).text() + " "; }); $("div").text(str); }) .change(); </script>** </head> <body> <div id="top_wrapper_bg"> <div id="wrapper_top"> <div id="header"> <div id="logo"> <a href="index.php"><img src="img/logo-02-01-11.png" alt="logo-02-01-11" width="300" height="100" border="0" /></a> </div><!-- /logo --> <div id="header_image"> right </div><! -- /header_image --> <div id="clear"> </div><! -- /clear --> <div id="nav"> nav </div><! -- /nav --> </div><!-- /header--> </div><!-- /wrapper_top --> </div><!-- /top_wrapper_bg --> <div id="header_search_break"> </div> <div id="bot_wrapper_bg"> <div id="wrapper_bottom"> <div id="search"> <span class="medfont">search by:</span> <form id="searchselect" action="#"> <input type="radio" name="option1" value="first name" />first name <input type="radio" name="option1" value="last name" />last name <input type="radio" name="option1" value="department" />department <input type="radio" name="option1" value="course" />course </form> <br> <input class="box" type="text" name="searchquery" value="select option..." class="textfield clearmefocus" /> </div><!-- /search --> <div id="latest_stats"> <p>stats</p> </div><!-- /latest_stats --> <div id="clear"> </div> <div id="contain_stats"> <div id="latest_prof"> latest prof </div><!-- /latest_prof --> <div id="top_prof"> top prof </div><!-- /top_prof --> <div id="clear"> </div><! -- /clear --> </div><!-- /contain_stats --> <br><br><br><br><br><br><br><br> <h6 style="margin:0; padding:0; font-size:0.3em;"><a href="prof.php">prof page</a></h6> </div><!-- /wrapper_bottom --> </div><!-- /bot_wrapper_bg --> </body> </html>
using code:
$(document).ready(function(){ $("input[type=radio]").click(function(){ $("#it").val(this.value); }); });
and html:
<input type="text" id="it" value=""> <input type="radio" name="hey" value="one"> <input type="radio" name="hey" value="two"> <input type="radio" name="hey" value="three">
this demonstrates concept of how it.
Comments
Post a Comment