在onchange函数中调用变量 [英] calling variable in onchange function
问题描述
我正在使用javafunction(onclick in select),其中我在php中调用了一个
函数(这就是为什么我将它发送到php和javascript
newsgroups )。
onclick中的
我调用函数Place_Selected使用来自
的值选择(naam_keuze.value)
函数中的值变为$ zoek_id并在数据库中搜索
为id为$ zoek_id的记录
naam_keuze.value没有给$ zoek_id值
当我取代naam_keuze.value一个数字(15)我工作得很好。
我做错了什么?
这是我的代码
函数Place_Selected($ zoek_id)
{
include(" data.php");
$ link = mysql_connect($ db_host,$ username,$ password)或死(数据库
错误!);
mysql_select_db($ database,$ link)或die( 无法打开$ db:
" .mysql_error());
$ sql = mysql_query(" SELECT * FROM specialismen WHERE id ='' $ zoek_id''");
if($ sql)
{
while($ blah2 = mysql_fetch_array($ sql))
{
$ newsid = $ blah2 [' 'id''];
$ sticky = $ blah2 [''naam''];
}
}
return(" document.form.achternaam.value =''$ sticky''");
}
< select id = naam_keuze size = 1 name = keuze style = visibility:hidden
onchange =" .Place_Selected(''naam_keuze.value'')。" ;; do cument.form.voornaam.value
= naam_keuze.value;>
< option value = 0> Kies
$期权
< / select>
感谢您的建议
roy
zoek_id和搜索在数据库中
为记录的id为
zoek_id
naam_keuze.value没有给出值
zoek_id
当我将naam_keuze.value替换为数字(15)时,我工作得很好。
我做错了什么?
这是我的代码
F取消Place_Selected(
I am using a javafunction (onclick in select) in which i am calling a
function in php (thats why i send this to both php and javascript
newsgroups).
in the onclick i call the function "Place_Selected" with the value from the
select (naam_keuze.value)
in the function the value becomes the $zoek_id and searches in the database
for the record with the id of $zoek_id
the naam_keuze.value does not give the value to $zoek_id
When i replace naam_keuze.value for a number (15) i works great.
WHAT AM I DOING WRONG?
This is my code
Function Place_Selected($zoek_id)
{
include("data.php");
$link=mysql_connect($db_host, $username, $password) or die("Database
error!");
mysql_select_db($database , $link)or die("Couldn''t open $db:
".mysql_error());
$sql=mysql_query("SELECT * FROM specialismen WHERE id=''$zoek_id''");
if ($sql)
{
while($blah2 = mysql_fetch_array($sql))
{
$newsid = $blah2[''id''];
$sticky = $blah2[''naam''];
}
}
return("document.form.achternaam.value=''$sticky''") ;
}
<select id=naam_keuze size=1 name=keuze style=visibility:hidden
onchange=".Place_Selected(''naam_keuze.value'').";do cument.form.voornaam.value
=naam_keuze.value;>
<option value=0>Kies
$options
</select>
Thanks for suggestions
roy解决方案zoek_id and searches in the database
for the record with the id of
zoek_id
the naam_keuze.value does not give the value to
zoek_id
When i replace naam_keuze.value for a number (15) i works great.
WHAT AM I DOING WRONG?
This is my code
Function Place_Selected(
这篇关于在onchange函数中调用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!