1

我正在为我的网站制作上传部分。当用户想要上传新的应用程序时,他们需要填写一个表格,其中放置版本号等。

可以上传 27 种不同的应用程序。为此我做了一个while循环

例子:

<select id="type">
<option value="choose" selected>choose here</option>
<?php

require("Function/applist.php");
while($showtablerow = mysql_fetch_array($showtablequery_result))
{
echo "<option value=".$showtablerow[0].">".$showtablerow[0]."</option>";
}

?>  
</select>   
</div>
<div id="choose" class="add" style="display:none;"></div>


<?php

require("Function/applist.php");
while($showtablerow = mysql_fetch_array($showtablequery_result))
{

    echo "<div class='add' id=".$showtablerow[0]." style='display:none;'><h2 id='amx-label'>".$showtablerow[0]."</h2>
    <div id='formadd' style='opacity:1;'>

    <form name='addamx' id='addamx' method='post'>

        <div id='version' class='uploadform' style='opacity:1;'>
            Version: <input style='opacity:1;' required type='text' name='versie' id='versie' width='3' onchange='process1()' ><br>

        </div>
        <div id='date' class='uploadform' style='opacity:1;'>
            Release Date(yyyy-mm-dd): <input required type='date' style='opacity:1;' size='10' maxlength='10' name='date'  id='date'>

        </div>
    <div id='build' style='opacity:1;'>
            Build By: <input required type='text' style='opacity:1;' size='5' maxlength='25' name='build'  id='build' >


        </div>
        <div id='platform' style='opacity:1;'>
            Platform: <span>32 Bit:</span><input required type='radio' style='opacity:1;' id='platform'  name='platform' value='32bit'>
                  <span>64 Bit:</span><input required type='radio' style='opacity:1;' id='platform'  name='platform' value='63bit'>
        </div>
        <div id='application'>
        <input type='hidden' name='app' value=".$showtablerow[0]." />
        </div>  
        <div id='notes' style='opacity:1;'>
            Release Notes: <textarea id='notess' name='test' onblur='process1()'></textarea>
        </div>

        <div id='uploadfooter' style='opacity:1;'>
            <button type='submit' id='uploadamx' name='uploadamx'>Upload
        </div>  
    </form>


    </div>



</div>";
}
?>

在选择框中,他们选择他们要上传的应用程序,并根据该选择获得一个表格。

在文本区域中,他们编写了发行说明。

我希望他们在填写版本号时自动将该版本号归档在文本区域中。

我有点使用以下javascript:

function process1() {
var appname = document.getElementById('type').value;
var version = document.getElementById('versie').value;
var textvalue = "changes for " + appname + " version " + version;

document.getElementById("notess").value = textvalue;

}

该功能仅适用于第一个表单 div 当我在第二个 div 上尝试它时,textarea 保持为空,并且第二个 div 的版本号从第一个 div 插入到 textarea

我如何制作该功能,以便 textarea 仅填充该表单中的版本号?有任何想法吗?

编辑***

AboQutiesh 是一个很好的启动方式,它唯一需要的调整是他写道: onblur='process1(".$showtablerow[0].")' result is onblur='process1(argument)' 这不起作用,因为参数需要 onblur='process1('argument')' 因为它在一个 while 循环中我不能只放 '' 因为它会破坏整个 onblurethansk 我的一个大学,他将我指向 ascii 表解决方案:

我将其更改为 onblur=process1('".$showtablerow[0]."')

(删除 ; 在 asccii 的末尾,否则它不会在此处正确显示)感谢启动 AboQutiesh

4

1 回答 1

0

您需要在 php 中为每个文本区域提供不同的 ID,如下所示:

    <div id='notes' style='opacity:1;'>
        Release Notes: <textarea id='notess_".$showtablerow[0]." name='test' onblur='process1(".$showtablerow[0].")'></textarea>
    </div>

在js中

    function process1(appId) {
     var appname = document.getElementById('type').value;
     var version = document.getElementById('versie').value;
     var textvalue = "changes for " + appname + " version " + version;

    document.getElementById("notess_"+appId).value = textvalue;
}

我认为这就是你需要的

于 2012-09-19T06:18:27.613 回答