我有这两个下拉菜单,根据选择生成一个弹出的图片。但我也希望在"查看您的产品"时,将所选值插入到同一页面上的文本中。按下按钮。
function f(){
var gid=function(i){return document.getElementById(i);};
var version_id=gid("two").value;
var arch_id=gid("three").value;
var width = 670;
var height = 800;
var left = (screen.width/2)-(width/2);
var top = (screen.height/2)-(height/2);
if( version_id ==='default' || arch_id === 'default'){return;}
window.open('images/shop/' + version_id + '_' + arch_id + '.jpg', "_blank",
'toolbar=no, location=no, directories=no, status=no, menubar=no,
scrollbars=no, resizable=no, copyhistory=no, width='+width+',
height='+height+',top='+top+', left='+left );
}
<p class="item_name1">Chose frame</p></br>
<select name="mycomp1" id="two" style="width:185px;" data-maincss="blue">
<option name="one" value="b1" title="images/black3.jpg"></option>
<option name="two" value="b2" title="images/silver.jpg"></option>
<option value="b3" title="images/white.jpg"></option>
</select>
<p class="item_name">Chose fabric</p></br>
<select name="mycomp2" id="three" style="width:185px;" data-maincss="blue">
<option name="one" value="c1" title="images/black.jpg"></option>
<option name="two" value="c2" title="images/green.jpg"></option>
<option value="c3" title="images/red.jpg"></option>
<option value="c4" title="images/blue.jpg"></option>
</select>
<input onclick="Javascript:f();" value="View your product" type="button"/>
答案 0 :(得分:1)
您可以根据自己的目的进行修改。
function f(){
var gid=function(i){return document.getElementById(i);};
var version_id=gid("two").value;
var arch_id=gid("three").value;
var width = 670;
var height = 800;
var left = (screen.width/2)-(width/2);
var top = (screen.height/2)-(height/2);
if( version_id ==='default' || arch_id === 'default'){return;}
var newWindow = window.open('images/shop/' + version_id + '_' + arch_id + '.jpg',"_blank",
'toolbar=no, location=no, directories=no, status=no,menubar=no,scrollbars=no, resizable=no,
copyhistory=no,width='+width+',height='+height+',top='+top+', left='+left);
}
//create scriptedText here before inserting
newWindow.document.getElementByd('textContainer').innerHTML = scriptedText;
我希望这会有所帮助