JimWorld Forums: Form and functionality



Posted By: mark_battista ()
Posted On: 11/21/2007 12:18 pm

Hi I run a rug retail website and we have a romancart checkout system installed that does everything we need however a lot of our rugs are available in custom sizes. What I need is some help to create maybe like a form type thing where a user enters the length and width of a rug that they require which then calculates length x width x cost per square metre to give them an actual price and then a button that they can press to add that rug code and price to the shopping cart. Help much appreciated, thanks in advance.



Posted By: animated3d ()
Posted On: 11/21/2007 01:39 pm

you would need a cgi script on your site to make that calculation, maybe you can download it somewhere and adjust it to your needs or make one specifically for your own site, they are usually coded with perl,asp,php etc..


Posted By: mark_battista ()
Posted On: 11/21/2007 01:44 pm

ok I have this, it works ok, the problem is I can't get it to submit the result to my shopping cart

<form action=http://www.romancart.com/cart.asp method=post>
<input type=hidden name=storeid value=16144>
<input type=hidden name=quantity value=1>
<tr>
<td valign=top bgcolor="#eeeeee" class="padded"><table border="0" cellspacing="0" cellpadding="0" class="choicebox" width="100%">
<tr>
<td align="center" width="50%" id="boxleft" name="boxleft" class="choiceoffleft">&nbsp;</td>
</tr>
</table>
<div name="custompricing" id="custompricing" class="TG_hidden">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="pricingbox"><script language="JavaScript" type="text/JavaScript">

<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"wink)>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function KW_getVal(o){ //v1.2
var retVal="0";if (o.type=="select-one"wink
{retVal=(o.selectedIndex==-1)?0:o.options[o.selectedIndex].value;}
else if (o.length>1){for (var i=0;i<o.length;i++) if (o.checked) retVal=o.value;
} else if (o.type=="checkbox"wink {retVal=(o.checked)?o.value:0;} else {
retVal=Number(o.value)}return parseFloat(retVal);
}

function KW_calcForm() { //v1.2
var str="",a=KW_calcForm.arguments; for (var i=3;i<a.length;i++)
str+=(a.indexOf("#"wink==-1)?a:KW_getVal(MM_findObj(a.substring(1)));
t=Math.round(a[1]*eval(str))/a[1];tS=t.toString();if(a[2]>0){tSp=tS.indexOf("."wink;
if(tSp==-1) tS+=".";tSp=tS.indexOf("."wink;while(tSp!=(tS.length-1-a[2])){tS+="0";
tSp=tS.indexOf("."wink;}} MM_findObj(a[0]).value=tS;
}
//-->

</script>
<table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td colspan="2"><p> Specify the size of the bespoke rug you wish to order below, then press the calculate button. </td>
</tr>

<tr>
<td colspan="2"><table width="100%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td nowrap>Width (cm)</td>
<td nowrap><input type=hidden name=catfactor value="135">
<input type=text size=5 name=rugwidth></td>
<td nowrap>Length (cm)&nbsp;&nbsp;&nbsp;&nbsp;
<input type=text size=5 name=ruglength>
&nbsp;&nbsp;&nbsp;
<input name="button" type="button" onClick="KW_calcForm('price',100,2,'(','(','#rugwidth','*','#ruglength',')','/','10000',')','*','135')" value="Calculate"></td>
</tr>
<tr>
<td nowrap>£ </td>
<td nowrap><input type=text size=5 name=price value="" disabled></td>
<td nowrap>&nbsp;</td>
</tr>
<tr>
<td align="left" nowrap colspan="3"><input type=submit value='Add to Basket'>
<input type=hidden name=productid value="1624">
<input type=hidden name=cat value="0">
</form>


JimWorld Forums © 1996 - 2004 .... iWeb Technology, Jimworld.com