Jump to content

Multiple subdomains - pass selected value?


sino

Recommended Posts

Hi,

 

We'd like to have a drop down menu to show the subdomains available for selection. We add the following code to products.tpl for testing purpose. We found that $product.pid doesn't pass to the URL when we submit the form.

 

<form method="post" action="{$smarty.server.PHP_SELF}?a=add&pid={$product.pid}">
<select name="pid[0]">
{foreach key=num item=product from=$products}
<option value="{$product.pid}"{if $product.pid eq $pid} selected="selected"{/if}>{$product.name}</option>
{/foreach}</select><input type="submit" value="{$LANG.go}" />
</form>

 

The drop down menu shows up correctly. However, URLs show as follows:

 

URL before clicking "go" button, i.e. submit the form

 

../cart.php?gid=2

 

URL after submitting the form

 

../cart.php?a=add&pid=

 

The pid value (selected subdomain) fails to pass to the URL. Please help. Thank you in advance.

 

P.S.: There are already a number of members here expressed the need of multiple subdomains support. For the time being, we wish to test thoroughly if WHMCS suits our needs.

 

Regards,

Sino

Edited by sino
correct grammar
Link to comment
Share on other sites

We found that $product.pid doesn't pass to the URL when we submit the form

 

Think logically about the code - you're setting the *action* before the user is making a *selection* ...

So no, it's not going to pass the value they pick to the URL ;)

 

You need to add onclick event to the submit to change the &pid=

Link to comment
Share on other sites

Think logically about the code - you're setting the *action* before the user is making a *selection* ...

So no, it's not going to pass the value they pick to the URL ;)

 

You need to add onclick event to the submit to change the &pid=

 

Hi othellotech,

 

Thank you for your advice. You're right. :oops: I've changed the code as follows:

 

<select name="pid[0]">

{foreach key=num item=product from=$products}

<option value="{$product.pid}"{if $product.pid eq $pid} selected="selected"{/if}>{$product.name}</option>

{/foreach}

</select>

<input type="submit" value="{$LANG.ordernowbutton}" onclick="window.location='{$smarty.server.PHP_SELF}?a=add&pid={$product.pid}'" />

 

Now it passes the pid value but only the last one, not the selected one. Still googling the answer. Thank you.

 

Regards,

Sino

Link to comment
Share on other sites

It works now. But the pid value dosen't show up in the URL.

 

<form method="post" action="{$smarty.server.PHP_SELF}?a=add&pid={$pid}&domainoption=subdomain">

<select name="pid">

{foreach key=num item=product from=$products}

<option value="{$product.pid}"{if $product.pid eq $pid} selected="selected"{/if}>{$product.name}</option>

{/foreach}

</select>

<input type="submit" value="{$LANG.ordernowbutton}" />

</form>

Link to comment
Share on other sites

I see your in a little pain with that... On the form action you don't put the pid as it is sent from the form itself.

[color=#000000][color=#007700]
<[/color][color=#0000bb]form method[/color][color=#007700]=[/color][color=#dd0000]"post" [/color][color=#0000bb]action[/color][color=#007700]=[/color][color=#dd0000]"{$smarty.server.PHP_SELF}?a=add&domainoption=subdomain"[/color][color=#007700]> 

<[/color][color=#0000bb]select name[/color][color=#007700]=[/color][color=#dd0000]"pid"[/color][/color] onchange="submit()"[color=#000000][color=#007700]> 

{foreach [/color][color=#0000bb]key[/color][color=#007700]=[/color][color=#0000bb]num item[/color][color=#007700]=[/color][color=#0000bb]product from[/color][color=#007700]=[/color][color=#0000bb]$products[/color][color=#007700]} 

<[/color][color=#0000bb]option value[/color][color=#007700]=[/color][color=#dd0000]"{$product.pid}"[/color][color=#007700]{if [/color][color=#0000bb]$product[/color][color=#007700].[/color][color=#0000bb]pid eq $pid[/color][color=#007700]} [/color][color=#0000bb]selected[/color][color=#007700]=[/color][color=#dd0000]"selected"[/color][color=#007700]{/if}>{[/color][color=#0000bb]$product[/color][color=#007700].[/color][color=#0000bb]name[/color][color=#007700]}</[/color][color=#0000bb]option[/color][color=#007700]> 

{/foreach} 

</[/color][color=#0000bb]select[/color][color=#007700]> 

<[/color][color=#0000bb]input type[/color][color=#007700]=[/color][color=#dd0000]"submit" [/color][color=#0000bb]value[/color][color=#007700]=[/color][color=#dd0000]"{$LANG.ordernowbutton}" [/color][color=#007700]/> 

</[/color][color=#0000bb]form[/color][color=#007700]>[/color][/color]

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated