I need to pass textbox value from redirected page into main page using javascript.On clicking 'select' button in findzipcode.cstml values from textbox are not passed into mainpage.cshtml.
function SendValueToParentZipCodeInfo() {
var myVal1 = document.getElementById('ZipCodetxt').value;
var myVal5 = document.getElementById('Citytxt').value;
var myVal3 = document.getElementById('statenametxt').value;
window.opener.GetValueFromChildZip(myVal1);
window.opener.GetValueFromChildCity(myVal5);
window.opener.GetValueFromChildState(myVal3);
window.close();
return false;
}
<div class="container">
<div class="panel panel-primary">
<div class="panel panel-heading">
<a href="#">
<span class="glyphicon glyphicon-home"></span>
</a>Find Zip/State/City
</div>
<div class="panel-body">
<form class="form-horizontal">
<div class="col-lg-11">
<div class="form-group">
<input type="text" id="ZipCodetxt" name="ZipCodetxt" style="width:65px" />
<input type="text" id="Citytxt" name="Citytxt" style="width:65px" />
<input type="text" id="statenametxt" name="StateCode" style="width:200px" />
<table id="MyTable" style="height:200px;width:115%;overflow-y:scroll;overflow-x:scroll;">
<tr class="header">
<th>ZipCode</th>
<th>CityName</th>
<th>StateCode</th>
</tr>
@foreach (var items in Model)
{
<tr onclick="javascript:showRow(this);">
<td>@items.ZipCode</td>
<td> @items.CityName</td>
<td>@items.StateCode</td>
</tr>
}
</table>
</div>
</div>
</form>
<div class="form-group">
<div class="col-md-8">
</div>
<div class="col-md-4">
<button type="submit" value="Clear">Clear Filter</button>
<button type="button" value="Select"onclick="javascript:returnSendValueToParentZipCodeInfo();">Select</button>
<button type="submit" value="Cancel">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</html>
MainPage.cshtml
<script>
function GetValueFromChildZip(myVal1) {
document.getElementById('ZipCodetxt').value = myVal1;
}
function GetValueFromChildCity(myVal5) {
document.getElementById('Citytxt').value = myVal5;
}
function GetValueFromChildState(myVal3) {
document.getElementById('statenametxt').value = myVal3;
}
</script>
<html>
<input type="text" id="ZipCodetxt" value="@Session["zipcodetxt"]" name="zipcodetxt" />
<input type="text" id="Citytxt" value="@Session["citynametxt"]" name="citynametxt" />
<input type="text" style="width:50px" id="statenametxt" value="@Session["statecodetxt"]" name="statecodetxt" />
</html>