Jump to content

contact-form how to do this...


aegypius3

Recommended Posts

I would like to do this in contact-form:

If "service client" is selected deploy the original contact-form.

If "Webmaster" is selected deploy another form with this fields

Name

Lastname

Phone

Address

 

I know how to add new fields and edit the controllers and mails but no idea how to separate what i want to appear if one is selected from the other.

 

HELP please

Link to comment
Share on other sites

I would like to do this in contact-form:

If "service client" is selected deploy the original contact-form.

If "Webmaster" is selected deploy another form with this fields

Name

Lastname

Phone

Address

 

I know how to add new fields and edit the controllers and mails but no idea how to separate what i want to appear if one is selected from the other.

 

HELP please

 

you must add to selectbox javascript action onchange="" where you put function to hide/remove wrong form fields

Link to comment
Share on other sites

can anyone do an example in the contact-form.tpl. If "service client" is selected deploy the original contact-form.

If "Webmaster" is selected deploy another form with this field.

 

Name

 

I´ll add the others fields. Thanks in advance.

Link to comment
Share on other sites

I´m not an expert so no idea how to do it... Maybe it´s too complicate to do it for me. Cause I think more modifications are needed.

 

In contact-form.tpl

{capture name=path}{l s='Contact'}{/capture}
{include file="$tpl_dir./breadcrumb.tpl"}
<h1>{l s='Customer Service'} - {if isset($customerThread) && $customerThread}{l s='Your reply'}{else}{l s='Contact us'}{/if}</h1>
{if isset($confirmation)}
<p>{l s='Your message has been successfully sent to our team.'}</p>
<ul class="footer_links">
 <li><a href="{$base_dir}"><img class="icon" alt="" src="{$img_dir}icon/home.gif"/></a><a href="{$base_dir}">{l s='Home'}</a></li>
</ul>
{elseif isset($alreadySent)}
<p>{l s='Your message has already been sent.'}</p>
<ul class="footer_links">
 <li><a href="{$base_dir}"><img class="icon" alt="" src="{$img_dir}icon/home.gif"/></a><a href="{$base_dir}">{l s='Home'}</a></li>
</ul>
{else}
<p class="bold">{l s='For questions about an order or for more information about our products'}.</p>
{include file="$tpl_dir./errors.tpl"}
<form action="{$request_uri|escape:'htmlall':'UTF-8'}" method="post" class="std" enctype="multipart/form-data">
 <fieldset>
  <h3>{l s='Send a message'}</h3>
  <p class="select">
<label for="id_contact">{l s='Subject Heading'}</label>
  {if isset($customerThread.id_contact)}
{foreach from=$contacts item=contact}
 {if $contact.id_contact == $customerThread.id_contact}
  <input type="text" id="contact_name" name="contact_name" value="{$contact.name|escape:'htmlall':'UTF-8'}" readonly="readonly" />
  <input type="hidden" name="id_contact" value="{$contact.id_contact}" />
 {/if}
{/foreach}
  </p>


//Here is where it is. If the first option is selected show the form like it comes, but if the second option is selected deploy a form with the fields spaced below.



  {else}
<select id="id_contact" name="id_contact" onchange="showElemFromSelect('id_contact', 'desc_contact')" >
 <option value="0">{l s='-- Choose --'}</option>
{foreach from=$contacts item=contact}
 <option value="{$contact.id_contact|intval}" {if isset($smarty.post.id_contact) && $smarty.post.id_contact == $contact.id_contact}selected="selected"{/if}>{$contact.name|escape:'htmlall':'UTF-8'}</option>
{/foreach}
</select>
  </p>
  <p id="desc_contact0" class="desc_contact"> </p>
{foreach from=$contacts item=contact}
 <p id="desc_contact{$contact.id_contact|intval}" class="desc_contact" style="display:none;">
  {$contact.description|escape:'htmlall':'UTF-8'}
 </p>
{/foreach}
  {/if}




	   <p class="text">
					<label for="contactperson">{l s='Contact Person'}</label>
					<input type="text" id="contactperson" name="contactperson" value="{if isset($contactperson)}{$contactperson|escape:'htmlall':'UTF-8'|stripslashes}{/if}" />
			</p>
			<p class="text">
					<label for="phonenumber">{l s='Phone Number'}</label>
					<input type="text" id="phonenumber" name="phonenumber" value="{if isset($phonenumber)}{$phonenumber|escape:'htmlall':'UTF-8'|stripslashes}{/if}" />
			</p>
			<p class="text">
					<label for="country">{l s='Country'}</label>
					<input type="text" id="country" name="country" value="{if isset($country)}{$country|escape:'htmlall':'UTF-8'|stripslashes}{/if}" />
			</p>  





  <p class="text">
<label for="email">{l s='E-mail address'}</label>
{if isset($customerThread.email)}
 <input type="text" id="email" name="from" value="{$customerThread.email|escape:'htmlall':'UTF-8'}" readonly="readonly" />
{else}
 <input type="text" id="email" name="from" value="{$email|escape:'htmlall':'UTF-8'}" />
{/if}
  </p>
{if isset($isLogged) && $isLogged}
 {if !$PS_CATALOG_MODE}
  {if (!isset($customerThread.id_order) || $customerThread.id_order > 0)}
  <p class="text select">
<label for="id_order">{l s='Order ID'}</label>
{if !isset($customerThread.id_order) && isset($isLogged) && $isLogged == 1}
 <select name="id_order" >
  <option value="0">{l s='-- Choose --'}</option>
  {foreach from=$orderList item=order}
   <option value="{$order.value|intval}">{$order.label|escape:'htmlall':'UTF-8'}</option>
  {/foreach}
 </select>
{elseif !isset($customerThread.id_order) && !isset($isLogged)}
 <input type="text" name="id_order" id="id_order" value="{if isset($customerThread.id_order) && $customerThread.id_order > 0}{$customerThread.id_order|intval}{else}{if isset($smarty.post.id_order)}{$smarty.post.id_order|intval}{/if}{/if}" />
{elseif $customerThread.id_order > 0}
 <input type="text" name="id_order" id="id_order" value="{$customerThread.id_order|intval}" readonly="readonly" />
{/if}
  </p>
  {/if}
		{/if}
  {if isset($isLogged) && $isLogged}
  <p class="text select">
  <label for="id_product">{l s='Product'}</label>
{if !isset($customerThread.id_product)}
{foreach from=$orderedProductList key=id_order item=products name=products}
 <select name="id_product" id="{$id_order}_order_products" class="product_select" style="width:300px;{if !$smarty.foreach.products.first} display:none; {/if}" {if !$smarty.foreach.products.first}disabled="disabled" {/if}>
  <option value="0">{l s='-- Choose --'}</option>
  {foreach from=$products item=product}
   <option value="{$product.value|intval}">{$product.label|escape:'htmlall':'UTF-8'}</option>
  {/foreach}
 </select>
{/foreach}
{elseif $customerThread.id_product > 0}
 <input type="text" name="id_product" id="id_product" value="{$customerThread.id_product|intval}" readonly="readonly" />
{/if}
  </p>
  {/if}
 {/if}
 {if isset($isLogged) && $isLogged}
 {if $fileupload == 1}
  <p class="text">
  <label for="fileUpload">{l s='Attach File'}</label>
<input type="hidden" name="MAX_FILE_SIZE" value="2000000" />
<input type="file" name="fileUpload" id="fileUpload" />
  </p>
 {/if}
	{/if}
 <p class="textarea">
  <label for="message">{l s='Message'}</label>
<textarea id="message" name="message" rows="15" cols="10">{if isset($message)}{$message|escape:'htmlall':'UTF-8'|stripslashes}{/if}</textarea>
 </p>
 <p class="submit">
  <input type="submit" name="submitMessage" id="submitMessage" value="{l s='Send'}" class="button_large" onclick="$(this).hide();" />
 </p>
</fieldset>
</form>
{/if}

Edited by aegypius3 (see edit history)
Link to comment
Share on other sites

Hi.

 

It will not be good that way. You do not need to add parameters to showElemFromSelect.

 

The showElemFromSelect will check which option is selected and show / hide the elements.

 

You can add the showElemFromSelect to a JS file of to the contact TPL.

 

Regards.

 

Robin.

 

The CartExpert Team

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...