Jump to content

ed0522

Members
  • Posts

    38
  • Joined

  • Last visited

1 Follower

Profile Information

  • First Name
    Yueguang
  • Last Name
    Wang

Recent Profile Visitors

95 profile views

ed0522's Achievements

Newbie

Newbie (1/14)

1

Reputation

  1. Click a button, it will add a row with 4 input fields in the table. When I save it, it will show the table I submitted.
  2. <form method="post" action="http://localhost/prestashop/en/index.php?fc=module&module=myregister&controller=cregisterProcess"> <div class="form-group"> <label for="name"><p style="color:#6E6E6E;">资格证书(点击添加)</p></label><br> <button type="button" onclick="addRow(this)" value=0 readonly="readonly" class="btn btn-info">外语</button> <button type="button" onclick="addRow(this)" value=1 readonly="readonly" class="btn btn-info">计算机</button> <button type="button" onclick="addRow(this)" value=2 readonly="readonly" class="btn btn-info">会计</button> <button type="button" onclick="addRow(this)" value=3 readonly="readonly" class="btn btn-info">职称</button> <button type="button" onclick="addRow(this)" value=4 readonly="readonly" class="btn btn-info">其他</button> </div> <table class="table table-bordered" id="skillsTable"> <thead> <tr> <th>技能</th> <th>分类</th> <th>资格考试</th> <th>分数/等级</th> <th>删除</th> </tr> <tr> <td>例:外语</td> <td>日语</td> <td>N1</td> <td>125</td> <td><button type="button" class="btn btn-default">删除</button></td> </tr> </thead> {for $i=1 to $rowNumbers} <tr> <td><input type="hidden" name="skills[]" class="form-control"readonly="readonly" value="{$skills[$i*4-4]}" id="usr">{$skills[$i*4-4]}</td> <td><input type="text" name="skills[]" class="form-control" value="{$skills[$i*4-3]}" id="usr"></td> <td><input type="text" name="skills[]" class="form-control" value="{$skills[$i*4-2]}" id="usr"></td> <td><input type="text" name="skills[]" class="form-control" value="{$skills[$i*4-1]}" id="usr"></td> <td><button type="button" onclick="delRow(this)" class="btn btn-default">删除</button></td> </tr> {/for} </table> JS: <SCRIPT> function addRow(button) { //Add row var addrow=skillsTable.insertRow(-1); var addCell01=addrow.insertCell(0); var addCell02=addrow.insertCell(1); var addCell03=addrow.insertCell(2); var addCell04=addrow.insertCell(3); var addCell05=addrow.insertCell(4); //Get events and info var bottonValue=button.value; if(bottonValue==0){ addCell01.innerHTML = '<input type="hidden" name="skills[]" class="form-control" value="外语" id="usr">外语'; }else if(bottonValue==1){ addCell01.innerHTML = '<input type="hidden" name="skills[]" class="form-control" value="计算机" id="usr">计算机'; }else if(bottonValue==2){ addCell01.innerHTML = '<input type="hidden" name="skills[]" class="form-control" value="会计" id="usr">会计'; }else if(bottonValue==3){ addCell01.innerHTML = '<input type="hidden" name="skills[]" class="form-control" value="职称" id="usr">职称'; }else if(bottonValue==4){ addCell01.innerHTML = '<input type="hidden" name="skills[]" class="form-control" value="其他" id="usr">其他'; } // Add values to the new cells: addCell02.innerHTML = '<input type="text" name="skills[]" class="form-control" id="usr">'; addCell03.innerHTML = '<input type="text" name="skills[]" class="form-control" id="usr">'; addCell04.innerHTML = '<input type="text" name="skills[]" class="form-control" id="usr">'; addCell05.innerHTML = '<button type="button" onclick="delRow(this)" class="btn btn-default">删除</button>'; } function delRow(rowNum) { var skillsTable=document.getElementById("skillsTable"); var rowNumber=rowNum.parentNode.parentNode.rowIndex; skillsTable.deleteRow(rowNumber); } </SCRIPT> PHP function: //getSkills $skills=Tools::getValue('skills'); var_dump($skills);
  3. Yes, I used the form label. The database shows "false", which means it saved nothing. I also tried the $_POST[], but the result is the same. The code worked well outside the prestashop.
  4. <input type="hidden" name="skills[]" class="form-control" value="职称" id="usr"> Why prestashop can't get value of skills[] with $skills=Tools::getValue('skills');? I have tested it in smarty environment, it worked. But when I copy to prestashop and revise the code, it doesn't work? What's wrong with that? Could anyone help me?
  5. If you add a field in the product.tpl, and use Tools::getValue() in cartController to get the value or you use $_POST[] mthod. I can't receive the value by using the both way. It seems that these methods don't work. But it shows mistakes which means that the code is compiled.
  6. sorry, i don't upload my website to the server. But I can show you more info. This is the link of the custom page. It's a tpl file in a custom module. http://localhost/prestashop/en/index.php?fc=module&module=myregister&controller=cer I won't show you the screenshot for it's not english. What I want is to submit a form to cart in this custom page.
  7. May be I can describe my question into how to submit a new field or add a new cart in a custom tpl file. You know, by default, we add a cart in product. tpl. Now I created a cer.tpl in a custom module and I want to add a cart in this file. Now the page can jump to the payment page. But it doesn't show the value of variable.
  8. There are 2 errors Product not found This product is no longer availaThere are 2 errors
  9. OK, thank you. I will have a try. It's really kind of you.
  10. I just pasted part of the code. What did you mean by showing me the whole code? I don't know why, it seems that the $this->context object doesn't work in my situation.
  11. I'm developing a module and I want to submit a cart from a tpl file (cer.tpl). Below is the code of the form in cer.tpl. <form role="form" action="{$link->getPageLink('cart')|escape:'html':'UTF-8'}" method="post"> <div class="form-group"> <textarea class="form-control" rows="3" name="consulting_Info" id="consulting_Info"></textarea> </div> <p class="hidden"> <input type="hidden" name="token" value="{$static_token}" /> <input type="hidden" name="id_product" value="{$product->id|intval}" id="product_page_product_id" /> <input type="hidden" name="add" value=1 /> <input type="hidden" name="id_product_attribute" id="idCombination" value=1 /> <input type="text" name="qty" id="quantity_wanted" class="text" value=1 /> <input type="text" name="test" id="test" class="text" value="TestValue" /> </p> <div class="no-print"> <button type="submit" name="Submit" class="exclusive"> </span>{l s='Add to cart'}</span> </button> </div> And I use Tools::getValue method to get the value of 'consulting_Info' field. In cartController.php public function init() { parent::init(); // Send noindex to avoid ghost carts by bots header('X-Robots-Tag: noindex, nofollow', true); // Get page main parameters $this->id_product = (int)Tools::getValue('id_product', null); $this->id_product_attribute = (int)Tools::getValue('id_product_attribute', Tools::getValue('ipa')); $this->customization_id = (int)Tools::getValue('id_customization'); $this->qty = abs(Tools::getValue('qty', 1)); $this->id_address_delivery = (int)Tools::getValue('id_address_delivery'); $this->consulting_Info = (int)Tools::getValue('consulting_Info'); $this->context->smarty->assign('consulting_Info', $consulting_Info); } Finally, I wrote {$consulting_Info} in shopping-cart.tpl, it showed the payment page, but it didn't show the value in onsulting_Info field.
  12. {if isset($empty)} <p class="alert alert-warning">{l s='Your shopping cart is empty11.'}</p> I'm wondering why I can't find $empty in orderController.php. In orderController.php, shopping-cart.tpl was set as template.
  13. I'm reading PS code, but I can't find the php file handling with $empty. Where is the file? Can someone help me? {if isset($empty)} <p class="alert alert-warning">{l s='Your shopping cart is empty.'}</p> {elseif $PS_CATALOG_MODE} <p class="alert alert-warning">{l s='This store has not accepted your new order.'}</p> {else}
  14. I didn't find it in frontcontroller.php. Are you sure it's here?
×
×
  • Create New...