javascript - How to capture text value from input field, and pass it to new input field -
i want couple of things happen simultaneously on keypress()
event, got 2 pages, default.html there input text box , page.html input text box, need moment key pressed type letter in input text box on default.html, keypress()
fires (i need on keypress, not on keyup or keydown) , 'letter' captured
var c = string.fromcharcode(e.which);
and @ same time page redirected
document.location= "page.html"; return false;
to 'page.html' showing 'letter' in input text field typed on previous page. have got incomplete code..
$(document).keypress(function(){ var c = string.fromcharcode(e.which); document.location= "page.html"; return false; } });
don't know how use var c here show value text field on next page(page.html).
javascript code on page.html...please correct , code.. picked post..i can see value typed on default.html page shows in address bar of page.html not show in input text box, know sure doing incorrectly. code mentioned below.
input field on default.html - <input id="search" type="text" name="searchbar">
input field on page.html - <input id="search2" type="text" name="searchbar2">
<script type="text/javascript"> var querystring = new array(); $(function () { if (querystring.length == 0) { if (document.location.search.split('?').length > 1) { var params = document.location.search.split('?')[1].split('&'); (var = 0; < params.length; i++) { var key = params[i].split('=')[0]; var value = decodeuricomponent(params[i].split('=')[1]); querystring[key] = value; } } } if (querystring["name"] != null) { var data = "<u>values querystring</u><br /><br />"; data += "<b>name:</b> " + querystring["name"]; $("#search1").html(data); } }); </script>
you can send character in query string this:
document.location = "page.html?c=" + c;
then, can read in javascript on page.html with
document.location.search
Comments
Post a Comment