在Javascript中使用隐藏字段值 [英] Use hidden field value in Javascript
本文介绍了在Javascript中使用隐藏字段值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的代码中,我想将区号替换为隐藏字段。
< script type = text / javascript src = http://maps.googleapis.com/maps/api/js?sensor=false\"></script>
< script type = text / javascript>
function InitializeMap()
{
var latlng = new google.maps.LatLng(-34。 397 , 150 . 644 );
var myOptions = {
zoom: 8 ,
center: latlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
var map = new google.maps。 Map ( document .getElementById( map ),myOptions);
}
window .onload = InitializeMap;
< / script>
< h2>创建您的第一个Google 地图演示:< / h2 >
< div id = map style = width:304px; top: 68px;左:172px;位置:绝对;高度:238px>
< / div >
解决方案
尝试类似
< pre lang =cs> var input = document.createElement( 输入跨度>);
input.setAttribute( type, hidden);
input.setAttribute( name, namegoeshere);
input.setAttribute( value, valuegoeshere);
// 附加到表单元素。
document.getElementById ( map)。appendChild(input);
希望这有帮助...
它不起作用:(
i尝试这种方式但仍然无法正常工作
< 脚本 类型 = text / javascript >
var map
函数InitializeMap(){
// var latlng = new google.maps.LatLng(21.543333,39.172778);
var latlng = new google.maps.LatLng('<% =会话( Airport)%> ');
var myOptions = {
zoom:11,
center:latlng,
mapTypeId:google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById(map),myOptions);
}
window.onload = InitializeMap;
var bikeLayer = new google.maps.BicyclingLayer();
bikeLayer.setMap(map);
< / script > 跨度>
In my code I would like to replace the area code to a hidden field.
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type ="text/javascript">
function InitializeMap()
{
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"), myOptions);
}
window.onload = InitializeMap;
</script>
<h2>Creating Your First Google Map Demo:</h2>
<div id ="map" style="width: 304px; top: 68px; left: 172px; position: absolute; height: 238px">
</div>
解决方案
Try something like
var input = document.createElement("input"); input.setAttribute("type", "hidden"); input.setAttribute("name", "namegoeshere"); input.setAttribute("value", "valuegoeshere"); //append to form element . document.getElementById("map").appendChild(input);
Hope this helps...
it is not work :(
i try this way but still not working
<script type ="text/javascript"> var map function InitializeMap() { // var latlng = new google.maps.LatLng(21.543333, 39.172778); var latlng = new google.maps.LatLng('<%=Session("Airport")%>'); var myOptions = { zoom: 11, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById("map"), myOptions); } window.onload = InitializeMap; var bikeLayer = new google.maps.BicyclingLayer(); bikeLayer.setMap(map); </script>
这篇关于在Javascript中使用隐藏字段值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文