Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
196 views
in Technique[技术] by (71.8m points)

javascript - JavaScript-动态ID的访问和操作(JavaScript - Acces And Operation on dynamic ID)

I have a problem with edit my calculator.

(我在编辑计算器时遇到问题。)

This is a old version :

(这是旧版本:)

<form method="post" action="wynik_baza_biala.php">
<div class ="cities">
<b>Wprowad? procentowo?? dodatkowego komponentu : </b> <br />`
<input type="text" name="komponent" id="komponent" value="0"><br />`
Pasta 1 :  <br /> `
<input type="text" name="pasta1" id="pasta1" value="0"><br />
Pasta 2 :  <br />
<input type="text" name="pasta2" id="pasta2" value="0"><br />
Pasta 3 :   <br />
<input type="text" name="pasta3" id="pasta3" value="0"><br />
Pasta 4 :  <br />
<input type="text" name="pasta4" id="pasta4" value="0"><br />
Pasta 5 :  <br />
<input type="text" name="pasta5" id="pasta5" value="0"><br />
Pasta 6 :  <br />
<input type="text" name="pasta6" id="pasta6" value="0"><br />
<b>BAZA</b> :  <br />
<input type="text" name="baza" id="baza" value="0"><br />
<input type="submit" value="Oblicz" name="submit" />

</div>

And The PHP CODE :

(和PHP代码:)

$komponent = $_POST['komponent'];
$pasta1 = $_POST['pasta1'];
$pasta2 = $_POST['pasta2'];
$pasta4 = $_POST['pasta4'];
$pasta5 = $_POST['pasta5'];
$pasta6 = $_POST['pasta6'];
$baza = $_POST['baza'];


$wynik_pasta1 = ($pasta1 * $wynik2) / $wynikx;
$wynik_pasta2 = ($pasta2 * $wynik2) / $wynikx;
etc.   

I know that this is not a proffesionall code but I study every day.

(我知道这不是专业代码,但我每天都在学习。)

So now I edit this proggram and I add a dynamic field in Java script :

(因此,现在我编辑该程序,并在Java脚本中添加一个动态字段:)

<input type="text", >
<div id="dynamicCheck">
<input type="button" value="Create Element"
onclick="createNewElement();"/>
</div>

<div id="newElementId">New inputbox goes here:</div>

<script type="text/javascript">
var x=1;
    function createNewElement() {
       x++;

 var txtNewInputBox = document.createElement("input");    
 txtNewInputBox.setAttribute("type","text");
  txtNewInputBox.setAttribute("id",x);
        txtNewInputBox.setAttribute("class","karol" );

document.getElementById("newElementId").appendChild(txtNewInputBox);

    }

</script> 

And My Question is : How i can get a Pass to dynamic ID on field create by user ?

(我的问题是:如何在用户创建的字段上获得动态ID的传递?)

For example : On old version a user write a number on "Pasta1" and php calculate it on :

(例如:在旧版本中,用户在“ Pasta1”上写一个数字,然后php在以下位置进行计算:)

$pasta1 = $_POST['pasta1']; and $wynik_pasta1 = ($pasta1 * $wynik2) / $wynikx;

How to make it in JavaScript ?

(如何用JavaScript制作?)

  ask by Karol G?owka translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Screen

(屏幕)

So now How I fetch on it in PHP ?

(那么现在如何在PHP中获取它呢?)

$pasta1 = $_POST['name2'] $pasta = $_POST['name3']

($ pasta1 = $ _POST ['name2'] $ pasta = $ _POST ['name3'])

etc ?

(等等?)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...