There is a text field that contains the name of the project and it looks like this:
$err=$my->out_branch_read("./project/".$name .".txt", "Name"); if ($my->out_branch_read!="") echo "<input type='text' id='ftp1' onkeyup='repeatTextFtp()' maxlength='25' size='100' name='new_project' value='$my->out_branch_read'></p>"; else echo "<input type='text' id='ftp1' onkeyup='repeatTextFtp()' maxlength='25' size='100' name='new_project'></p>";
There is also a field that contains the path to external resources:
$all_resurs=""; $err=$my->out_branch_read("./project/".$name .".txt", "Ftp"); if ($my->out_branch_read!=""){ echo "<p style='margin:20px'> <input type='checkbox' name='ftp' value='true' checked onclick='return ShowArea(this.form, 35)'>Копирование на общедоступный ресурс и на FTP</p>"; if ($my->out_branch_read=="true") $all_resurs=""; else $all_resurs=$my->out_branch_read; echo "<div id=resurs_b style='display:block; margin:30px'> <div class='name'>Общедоступный ресурс: <div class='cmd'><input type='text' id='ftp2' maxlength='250' size='80' name='all_resurs' value='$all_resurs' ></div></div>";
etc. (the rest is not so important, there is something else left)
Thus, if the project name is called TEST_1, then the path to the resource will be, for example, such \\ STORE \ MYCATALOG \ Branches \ 04 \ TEST_1
I try to make it so that when the name of the project changes, its name changes in the path to the resource. I do it like this:
function repeatTextFtp() { if (document.getElementById("ftp1").value=="$name"){ document.getElementById("ftp2").value='$_POST["all_resurs"]'; }else{ document.getElementById("ftp2").value='"\\\\STORE\\MYCATALOG\\Branches\\04".$_POST[new_project].""'; } }
$ name is the name of the project already recorded in TEST_1.txt, that is, its old name.
But the way is being recorded all the time, i.e. "\\ STORE \ MYCATALOG \ Branches \ 04". $ _ POST [new_project]. ""
Because of my inexperience, I most likely document.getElementById ("ftp2"). Value assign an incorrectly formed value, or the variables $ name and $ _POST [new_project] need to be declared earlier.
Maybe there are other ways to implement, not so cumbersome. After all, it is important for me to take into account that the field with the resource can be manually changed regardless of the project. And in general, as I understood, $ _POST is the same php-effective method. And in javascript, how is it written / used?
document.getElementById("ftp1").setAttribute(value, "некоторое значение")
. If you have a $ name variable then the quotes are not needed, but in javasctipt the variables are set differently than in php. $ _POST in javasctipt is not needed because it works on the client side, and $ _POST is an option to send data to the server. - Dmitriy Kondratiukfunction repeatTextFtp() { document.getElementById("ftp2").value='\\\\STORE\\MYCATALOG\\Branches\\04\\'+document.getElementById("ftp1").value; }
function repeatTextFtp() { document.getElementById("ftp2").value='\\\\STORE\\MYCATALOG\\Branches\\04\\'+document.getElementById("ftp1").value; }
. I do not make out the answer, because I am not sure about it. - Stepan Kasyanenko