Forum Moderators: open

Message Too Old, No Replies

Can anyone help me with this script

HTML submit button

         

chrisholgate

10:17 pm on Mar 23, 2003 (gmt 0)

10+ Year Member



Hi All,
I'm having a little bit of a problem with the POST action on my website and I know very little about HTML so I was hoping that someone out there could help me out.

Basically, the story goes as follows; I currently use the following script to post quantities of a product required from my website to Mals E-commerce shopping cart:

<form action="http server host goes here, blanked for Webmaster world" method="post">
<input size="4" name="qty1" value="1">
<input type="submit" name="SubmitBtn" value="Add to Cart">
<input type="hidden" value="64101274" name="userid">
<input type="hidden" value="Epson Stylus Colour 400/800/800+/1000 (S020025): Black Compatible Cartridge" name="product1">
<input type="hidden" value="2.89" name="price1">
</form>

Now the problem comes in the fact that I want to be able to offer price breaks if more than 6 items are ordered. The only way I have been able to do it is by having two submit buttons, one if the customer wishs to order less than 6 and one if they wish to order 6 or above.

Is there anyway that if "qty1"'s value is 6 or higher that I could then make

<input type="hidden" value="2.29" name="price1">

or a similar lower price to reflect that my customer is ordering 6 or more items?

Does this make sense to anybody? Any help you could give would be most apprechated.

Kind Regards

Chris Holgate

txbakers

10:25 pm on Mar 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



makes perfect sense.

There is a javascript way to do this.

Basically, don't use a "submit" button. Use a "button" button with an onClick to a javascript function, which will set the proper values for the form action.

If you need it written, someone might be able to dash it out for you.

chrisholgate

11:32 pm on Mar 24, 2003 (gmt 0)

10+ Year Member



Okay, many thanks for your help. If anybody happens to have some Javascript handy that could achieve this then please let me know but otherwise, not a problem, my web-designer said that he's give it a shot!

Kind Regards and thanks all.

Chris

jatar_k

11:43 pm on Mar 24, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



<form name="orderform" action="scriptname" method="post">
<input size="4" name="qty1" value="1">
<input type="button" name="SubmitBtn" value="Add to Cart" onClick="javascript:checkit();">
<input type="hidden" value="64101274" name="userid">
<input type="hidden" value="Epson Stylus Colour 400/800/800+/1000 (S020025): Black Compatible Cartridge" name="product1">
<input type="hidden" value="2.89" name="price1">
</form>

function checkit () {
if (document.orderform.qty1.value > 6) {
document.orderform.price1.value = 2.29;
}
document.orderform.submit();
}

I think that would work.