gpt4 book ai didi

javascript - 读取单击的下拉列表值而不提交

转载 作者:行者123 更新时间:2023-12-03 00:51:52 27 4
gpt4 key购买 nike

我怎样才能完成我的职责范围?单击下拉列表(语言)中的项目后,我希望在网页上有一个带有一些静态选项的下拉列表

<td align="left">&nbsp;&nbsp;&nbsp;
<SELECT name="language" >
<OPTION value="ro" selected>Romana</OPTION>
<option value="en">English</option>
<option value="de">Deutsch</option>
</SELECT>

选择一个我希望 $language 变量获取新值的选项值并重新加载页面,并更改 $language 变量。在目标网页上,我得到了一个 PHP 函数,该函数根据 $language 变量值返回 HTML 文本元素(这部分已经在工作)。以下是我的完整设置:index.php

<?php

if( isset( $_GET['target'] ) )
$target = $_GET['target'];
else
$target = "productie";

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
<!-- saved from url=English/index.php -->
<HTML><HEAD><META content="IE=7.0000" http-equiv="X-UA-Compatible">
<TITLE>website name</TITLE><!--

-->

</HEAD>
<FRAMESET frameSpacing=0 border=0 frameBorder=NO rows=65,* cols=*>
<FRAME noResize marginHeight=0 src="web_files/top.html" name=topFrame marginWidth=0 scrolling=no>
<FRAMESET frameSpacing=0 border=0 frameBorder=NO cols=224,*>
<FRAME noResize marginHeight=0 src="web_files/menu.php?target=<?php echo $target?>" name=leftFrame marginWidth=0>
<FRAME marginHeight=0 src="web_files/right.php?target=<?php
echo $target;
if( isset( $_GET['id'] ) )
?>" name="contentFrame" id="content" marginWidth=0>
</FRAMESET>
</FRAMESET>
</HTML>

下一个是 menu.php 我想在这里放入选项列表

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0099)http://w01abin05/intranet/english/navigation/Control.php -->
<HTML><HEAD><META content="IE=5.0000" http-equiv="X-UA-Compatible">
<TITLE>TAKATA</TITLE><!--
-->
<LINK rel=stylesheet
type=text/css href="Control_files/style_header.css">
<SCRIPT language=JavaScript type=text/JavaScript
src="Control_files/script.js"></SCRIPT>

<SCRIPT language=JavaScript type=text/JavaScript>
var i = "leer";
function highlight (id)
{
if(i!='leer')
document.getElementById(i).style.color="#ffffff";

document.getElementById(id).style.color="#000000";
i=id;
}

function changeOver(id)
{
if(id!=i)
document.getElementById(id).style.color="#000000";
}

function changeOut(id)
{
if(id!=i)
document.getElementById(id).style.color="#ffffff";
}
</SCRIPT>

<META name=GENERATOR content="MSHTML 10.00.9200.17028"></HEAD>
<BODY background="Control_files/bg_navi2.jpg" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<TABLE height="96%" cellSpacing=0 cellPadding=0 width=208 border=0>
<TBODY>
<TR>
<TD class=blue12bold vAlign=top background="Control_files/bg_navi.gif" height="5%"><BR />&nbsp;&nbsp;&nbsp;Rapoarte OPFSYS</TD></TR>
<TR >
<TD vAlign=top height="2%" valign="top" <?php if( $_GET['target'] == 'productie' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=productie" target="_parent">Raport productie</a></TD></TR>
<TR >
<TD vAlign=top height="2%" valign="top" <?php if( $_GET['target'] == 'productie_celule' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=productie_celule" target="_parent">Productie celule</a></TD></TR>
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'id_details' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=id_details" target="_parent">Trasabilitate piesa</a></TD></TR>
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'pontaj' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=pontaj" target="_parent">Pontaj celule</a></TD></TR>
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'wip' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=wip" target="_parent">Piese in lucru</a></TD></TR>
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'rework' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=rework" target="_parent">Reparatii</a></TD></TR>
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'logistics' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=logistics" target="_parent">Raport logistica</a></TD></TR>
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'perf_celule' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=perf_celule" target="_parent">Performanta celule</a></TD></TR>
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'downtime' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=downtime" target="_parent">Raport intreruperi</a></TD></TR>
<!--
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'new_report' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=new_report" target="_parent">Raport nou</a></TD></TR>
!-->
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'first_time' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=first_time" target="_parent">First Time Pass</a></TD></TR>
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'qgate' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=qgate" target="_parent">Raport Q-gate</a></TD></TR>

<TR>
<TD vAlign=top height="2%">&nbsp;&nbsp;&nbsp;<a href="/OPFSYS/web/" target="_blank">Ajustare performanta</a></TD></TR>
<TR>
<TD vAlign=top height="2%">&nbsp;&nbsp;&nbsp;<a href="http://server1/portal" target="_blank">Helpdesk PE-IT</a></TD></TR>

<!--
<TR>
<TD vAlign=top height="2%">&nbsp;&nbsp;&nbsp;<a href="../index.php?target=combined" target="_parent">Raport combinat</a></TD></TR>
!-->
<tr>
<TD class=blue12bold vAlign=top background="Control_files/bg_navi.gif" height="5%"><BR />&nbsp;&nbsp;&nbsp;Rapoarte Montaj</TD></TR>
<TR>
<TR>
<TD vAlign=top height="2%" <?php if( $_GET['target'] == 'bmw_ms_fa_control' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=bmw_ms_fa_control" target="_parent">Control BMW MS</a></TD></TR>
<TR><TD vAlign=top height="2%" <?php if( $_GET['target'] == 'bmw_ukl_opc' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=bmw_ukl_opc" target="_parent">Log OPC BMW UKL</a></TD></TR>
<TR><TD vAlign=top height="2%" <?php if( $_GET['target'] == 'labelling' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=labelling" target="_parent">Reetichetare</a></TD></TR>
<tr>
<TD class=blue12bold vAlign=top background="Control_files/bg_navi.gif" height="5%"><BR />&nbsp;&nbsp;&nbsp;Rapoarte Turnatorie</TD></TR>
<TR>
<TR>
<TD vAlign=top height="2%"<?php if( $_GET['target'] == 'dc_dot_marking' ) echo " bgcolor=\"#A0A0A0\" ";?>>&nbsp;&nbsp;&nbsp;<a href="../index.php?target=dc_dot_marking" target="_parent"><img src="Control_files/circle_big.png" style="width:5px;height:5px;" alt="dot" border="0"> marking</a></TD></TR>
<TR>
<TD vAlign=bottom align=left ><IMG src="Control_files/nav_logo.gif"
width=47 height=211>
</TD>
</TR>
</TBODY>
</TABLE>

</BODY></HTML>

最佳答案

您可以使用 onchange 获取新选择的选项的值事件。

$(document).ready(function(){
$('select[name=language]').change(function() {

});
});

如果您想提交数据,请添加ajax post

$(document).ready(function(){
$('select[name=language]').change(function() {
var _lang = $( "select['name=language'] option:selected" ).text(); //Get the text of the selected option, you can use .val() instead to get the the content of the value attribute
$.post( "languageHandler.php",{ language: _lang}, function(data) {
$('body').append(data); //Append the new data to body
});

});
});

关于javascript - 读取单击的下拉列表值而不提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53010584/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com