[英]how can i get the value of my input form be a javascript/php variable?
I can't get the value of the very last line of this code to be anything but static.除了 static 之外,我无法得到此代码最后一行的值。 I need it to be hardcoded so when they pull down the menu and select, it takes that value and puts it forth into the action script.
我需要对其进行硬编码,因此当他们下拉菜单和 select 时,它会采用该值并将其放入操作脚本中。
Any help?有什么帮助吗?
<select id="yo5" onChange="asdf90()"><option>// Let the Page Refresh for each Pick Please!</option>
<option id="yo4" value="<?php echo $test1 ?>"><?php echo $test1 ?></option>
<option value="<?php echo $test2 ?>"><?php echo $test3 ?></option>
<option><?php echo $test4 ?></option>
<option><?php echo $test5 ?></option>
<option><?php echo $test6 ?></option>
<option><?php echo $test7 ?></option>
<option><?php echo $test8 ?></option>
<option><?php echo $test9 ?></option>
<option><?php echo $test10 ?></option>
</select>
<script type = "text/javascript">
function asdf90()
{
elem = <?php $test1 ?>;
if(document.getElementById('yo5').value = elem)
{
alert('hi');
}
}
</script>
<form method="post" action="<?php echo network_admin_url('site-new.php?action=add-site'); ?>">
<div id="nonexsist4"><input name="blog[domain]" type="hidden" value="" /></div>
Put semi-colons after your echo statements..在您的回声语句后加上分号..
<option><?php echo $test9; ?></option>
And use the ==
operator, not =
并使用
==
运算符,而不是=
if(document.getElementById('yo5').value == elem)
The code had several errors.代码有几个错误。 I quote the correct code:
我引用了正确的代码:
<select id="yo5" onChange="asdf90()">
<option id="yo4" value="<?php echo $test1; ?>"><?php echo $test1; ?></option>
<option value="<?php echo $test2; ?>"><?php echo $test3; ?></option>
<option><?php echo $test4; ?></option>
<option><?php echo $test5; ?></option>
<option><?php echo $test6; ?></option>
<option><?php echo $test7; ?></option>
<option><?php echo $test8; ?></option>
<option><?php echo $test9; ?></option>
<option><?php echo $test10; ?></option>
</select>
<script type = "text/javascript">
function asdf90()
{
var elem = "<?php echo $test1; ?>";
if(document.getElementById('yo5').value == elem)
{
alert('hi');
}
}
</script>
Regards问候
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.