EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: alphasil on February 05, 2015, 06:33:26 AM



Title: php echo in form
Post by: alphasil on February 05, 2015, 06:33:26 AM
Hi

I'm having a problem getting my php variable into the form, without that i can't create a new record since the database expect that value

My form is called when i press the "new" button

Code:
      <div id="dlg" class="easyui-dialog" style="width:800px;height:500px;padding:10px 20px"
         closed="true" buttons="#dlg-buttons">
         <div class="ftitle">Nova Atividade</div>
         <form id="fm" method="post" novalidate>
            <div class="fitem">
               <label>Cargo:</label>
               <select name="cargo" id="cargo_name"></select>
            </div>
            <div class="fitem">
               <label>Atividade:</label>
               <input name="nome" required="true" class="easyui-textbox" size="60">
            </div>
            <div class="fitemdatahora">
               <label>Data:</label>
               <input name="data" class="easyui-datebox" id="data" size="30">
            </div>
            <div class="fitemdatahora">
               <label>Hora:</label>
               <input id="hora" class="easyui-timespinner" name="hora">
            </div>
            <div class="fitem">
               <label>Local:</label>
               <input name="local" class="easyui-textbox" required="true">
            </div>
            <div class="fitem">
               <label>Intervenientes:</label>
               <input name="inter" class="easyui-textbox" required="true">
            </div>
            <div class="fitem">
               <label>Notas:</label>
               <input name="notas" id="notas" size="60">
            </div>
            <div class="fitem">
<input type="text" name='iduser' id='iduser' value="<?php echo var_dump($userid); ?>">
</div>
         </form>
      </div>
      <div id="dlg-buttons">
         <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="saveUser()" style="width:90px">Registar</a>
         <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancelar</a>

This is where my php variable should be

Code:
<input type="text" name='iduser' id='iduser' value="<?php echo ($userid); ?>">

Outside the form, the variable is filled...so what's wrong? any help?


Title: Re: php echo in form
Post by: stworthy on February 05, 2015, 08:11:13 AM
How do you call your form when pressing the 'new' button? Please show some code snippets to describe it.


Title: Re: php echo in form
Post by: alphasil on February 06, 2015, 05:48:21 AM
Hi

Thanks for your reply

Code:
function novaAtividade(txt){
          $('#dlg').dialog('open').dialog('setTitle','Registar Nova Atividade');
txt = <?php echo $userid?>;
return txt;
          $('#fm').form('clear');
          }

function update() {
var iduser = <?php echo $userid?>;
$("#userid").attr("value",iduser);
}
window.onload = update;

Now is working, i calling that function in my form

Code:
<form id="fm" method="post" action="javascript:update()" novalidate>