sino Posted April 18, 2010 Share Posted April 18, 2010 (edited) 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 April 18, 2010 by sino correct grammar 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted April 18, 2010 Share Posted April 18, 2010 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= 0 Quote Link to comment Share on other sites More sharing options...
sino Posted April 19, 2010 Author Share Posted April 19, 2010 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. 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 0 Quote Link to comment Share on other sites More sharing options...
sino Posted April 19, 2010 Author Share Posted April 19, 2010 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> 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted April 19, 2010 Share Posted April 19, 2010 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] 0 Quote Link to comment Share on other sites More sharing options...
sino Posted April 19, 2010 Author Share Posted April 19, 2010 Sparky. You are great. Thank you. 0 Quote Link to comment Share on other sites More sharing options...
sparky Posted April 19, 2010 Share Posted April 19, 2010 hey settle... my head may explode No problem 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.