PDA

View Full Version : Help with displaying all details


loftty
12-27-2003, 08:37 AM
Dear All,

Hope you all had a lovely christmas?

I have this little part of a page.

But when you hit the checkboxes it displays the total value of all the boxes that the user has checked. This is fine.

But I want to be able to display all the items he has checked plus the value of that item next to it. and then below show up all the values.

could someone please help me?
Thnaks
L

here is the link to my little part of the page.

loftty
12-27-2003, 10:59 AM
Hello everyone,

Come on someone must be able to help?

Loftty

Willy Duitt
12-27-2003, 12:31 PM
Try this:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<html>
<head>
<title>Untitled</title>


<script>

function getRunningTotal(){
var allInputs=document.body.getElementsByTagName("INPUT");
howmany=1;
productList='';
runningTotal=0;
for(i=0;i<allInputs.length;i++){
if(allInputs[i].type.toLowerCase()=="checkbox"){
if(allInputs[i].getAttribute('cost')){
if(allInputs[i].checked){
productList=productList+'ITEM:'+howmany+'\) '+allInputs[i].getAttribute('name')+' PRICE: £'+allInputs[i].getAttribute('cost')+'<br>';howmany++;
runningTotal=runningTotal+parseInt(allInputs[i].getAttribute('cost'));
}
}
}
}
}
</script>
</head>
<body>

<TABLE borderColor="#ffffcc" bgColor="#c0c0c0" borderColorLight="#cc00ff"
border=5>


<TBODY>

<TR>


<TD><FONT size=4><STRONG>ACT! FOR LINE
50</STRONG></FONT></TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD><FONT size=4><STRONG>Support Cover</STRONG></FONT></TD><TD vAlign="center"></TR>

<TR>
<TR>
<TD vAlign="top"><STRONG>ACT! for Line 50 - Single User</STRONG></TD>
<TD vAlign="top">

<INPUT type="checkbox" onclick="getRunningTotal();" value="ON" cost="140" name="priceActline50SingleUser"></TD>
<TD vAlign="top">£140.00 <FONT size="1">Normal price is £199</FONT></TD>
<TD vAlign="top">

<INPUT type="checkbox" onclick="getRunningTotal();" value="ON" cost="120.50" name="supportActline50SingleUser"></TD>
<TD
vAlign="top">£120</TD></TR>
<TR>
<TD vAlign="top"><STRONG>ACT! for Line 50 - 5 Users</STRONG></TD>
<TD vAlign="top">

<INPUT type="checkbox" onclick="getRunningTotal();" value="ON" cost="600" name="priceActline50FiveUser"></TD>
<TD vAlign="top">£600.00 <FONT size="1">Normal price is £900</FONT></TD>
<TD>

<INPUT type="checkbox" onclick="getRunningTotal();" value="ON" cost="400" name="supportActline50FiveUser"></TD>
<TD vAlign="top">£400</TD></TR>
<TR>
<TD><STRONG>ACT! for Line 50 - 10 Users</STRONG></TD>
<TD>

<INPUT type="checkbox" onclick="getRunningTotal();" value="ON" cost="1155" name="priceActline50TenUser"></TD>
<TD vAlign="top">£1155.00 <FONT size="1">Normal price is £1650</FONT></TD>
<TD>

<INPUT type="checkbox" onclick="getRunningTotal();" value="ON" cost="500" name="supportActline50TenUser"></TD>
<TD vAlign="top">£500</TD></TR>

<TR>
<TD><STRONG>ACT! for Line 50 - 15 Users</STRONG></TD>
<TD>
<P><INPUT type="checkbox" onclick="getRunningTotal();" value="ON" cost="1680" name="priceActline50FifteenUser"></TD>
<TD vAlign=top>£1680.00 <FONT size=1>Normal price is £2400</FONT></TD>
<TD>

<INPUT type="checkbox" onclick="getRunningTotal();" value="ON" cost="600" name="supportActline50FifteenUser"></TD>
<TD vAlign=top>£600</TD></TR>
<TR>
<TD><STRONG>ACT! for Line 50 - 20 Users</STRONG></TD>
<TD>

<P><INPUT type="checkbox" onclick="getRunningTotal();" value="ON" cost="2200" name="priceActline50TwentyUser"></TD>
<TD vAlign=top>£2200.00 <FONT size=1>Normal price is £3150</FONT></TD>
<TD>

<P><INPUT type="checkbox" onclick="getRunningTotal();" value="ON" cost="700" name="supportActline50FifteenUser"></TD>
<TD vAlign=top>£700</TD></TR>
<TR>

<TD><STRONG>More then 20 Users - Call for our discount
Price</STRONG></TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD></TR></TBODY></TABLE></TD>

<STRONG> Please Hit Submit To Add And View Your Totals

<input type=submit value=submit onclick="result=window.open('','results','width=650,height=550'); result.document.writeln(productList+'<br><br>The total is: £' +runningTotal+ '<br>The total plus VAT is: £' + ((1.175 * runningTotal) + 6) + '<br><br>Contact us: Send an email to <a href=\'mailto:lofty@hotmail.net\'>Lofty</a>');" />



<TD>&nbsp;</TD></TR>
<TR>
<TD width=120>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD></TR>
<TR>
<TD width=1200>&nbsp;</TD>
<TD>&nbsp;</TD>
<TD>&nbsp;</TD></TR>
<TR>
<TD width=120>&nbsp;</TD>


<H1 style="TEXT-ALIGN: center" align=center><FONT face="Trebuchet MS"
color=#ff0000 size=4>Or Call Us On 0800 080808</FONT></H1>
</body>
</html>


.....Willy

Edit: Repaired the backslashes the forum removed
in the mailto anchor when originally posted.

loftty
12-27-2003, 01:36 PM
Hello Willy,

Thanks for the reply.

But for some reason it is not working, there is no window that displays anything.

what is the problem here?

Thanks
Loftty

Willy Duitt
12-27-2003, 02:11 PM
Try escaping the single quotes in your mailto: anchor.

eg:<a href=\'mailto:lofty@hotmail.net\'>Lofty</a>

Those single quotes are acting as delimiters
and are breaking the string.

.....Willy

BTW: If you are using IE make sure your Script
Debugging is activated. This way, you can find these
errors yourself. Tools --> Advanced

loftty
12-27-2003, 02:25 PM
Thanks alot Willy I realy am grateful for that.

is there a way that when the user clicks on the email link, the text that is on the window which display the totals plus the items will automatically be in the email text page ready to send?

thanks again willy
Loftty

Willy Duitt
12-27-2003, 02:50 PM
Originally posted by loftty
Thanks alot Willy I realy am grateful for that.

is there a way that when the user clicks on the email link, the text that is on the window which display the totals plus the items will automatically be in the email text page ready to send?

thanks again willy
Loftty

This was all discussed weeks ago here (http://www.htmlforums.com/showthread.php?s=&threadid=31627) and here (http://www.htmlforums.com/showthread.php?s=&threadid=32030) and probably elsewhere....

The use of Mailto: is completely unreliable. Depending on a users email client (if they even have one) the form results may or may not be passed. Outlook Express does not pass form results!

For reliability, you need to use serverside scripting to process the form results. If you must use Mailto: search the forums, there are several posts I have made which show how to use hidden spans to successfully pass the form results while using Mailto:

Perhaps now you understand why I previously suggested that you answer several pointed questions so that you (or anyone helping you) can have a clear understanding of where you are going with this, and exactly what your requirments are.

.....Willy

Willy Duitt
12-27-2003, 04:43 PM
Although UCM did a fine job of writing you the script you
are using. He only wrote a script that answered your
question at the time and does not address the issues of
displaying the order or processing the form.
Both of which you should have forseen

Although I am not inclined to rewrite the entire script.
For giggles I incorporated my mailto method to be used
with your current script.

To avoid the forum from breaking the script, I have attached it below.
Change the .txt extension to .html to use

Good Luck;
.....Willy

loftty
12-28-2003, 08:18 AM
Hello Willy,

Thanks for that it worked well.

in my outlook express when it opens it displays the items and the values, which is fine.

how do i get it to display other text like dear sir/madam or I would like to order something, at the top of the text editor?

somthing like this
/

Dear sir/madam

I would like to order these items.

ITEM:1) priceActline50TwentyUser PRICE: £2200
The total is:1 £2200
The total plus VAT is: £2591

Thankyou.
/

thanks again willy

Loftty

Willy Duitt
12-28-2003, 09:09 AM
Place whatever you want passed in a <div></div> wrapper.
function showIt(){
result=window.open('','results','width=650,height=550');
result.document.writeln('<form name="MAIL" method="POST" action="" enctype="text/html">');
result.document.writeln('<div>Dear sir/madam</div>');
result.document.writeln('<div> </div>');
result.document.writeln('<div>I would like to order these items.</div>');
result.document.writeln('<div> </div>');
result.document.writeln('<div> </div>');
result.document.writeln(productList);
result.document.writeln('<div> </div>');
result.document.writeln('<div>The total is: £'+runningTotal+'</div>');
result.document.writeln('<div>The total plus VAT is: £'+((1.175*runningTotal)+6)+'</div>');
result.document.writeln('<div> </div>');
result.document.writeln('<div> </div>');
result.document.writeln('<div>Thank You;</div>');
result.document.writeln('<input type="button" value="Submit" onclick="mailIt()">');
result.document.writeln('</form>');
result.document.writeln('<scr'+'ipt type="text/javascript">');
result.document.writeln('function mailIt(){paras=document.getElementsByTagName("div");'
+'var msg="";for(i=0;i<paras.length;i++)msg+=paras[i].innerHTML+"\\n";msg=(escape(msg));'
+'document.MAIL.action="mailto:lofty@hotmail.net?subject=Order Form&body="+msg;'
+'document.MAIL.submit();}');
result.document.writeln('</scr'+'ipt>');
}

.....Willy

BTW: Use the attached script instead of the previous one.
I have updated it to include your changes and
I had left a non-used function within the other script.

loftty
12-28-2003, 03:21 PM
Dear Willy,

I am most grateful for your help, but I have one problem with this.
the problem is that when you open the first window it also displays the dear sir/madam etc text in this window, but I only want it in the email text editor, could you please help?

also when I use MSN to send the mail it puts the subject (orderform) into the name of the person to send it to.
why is this?

Thanks
Loftty

Willy Duitt
12-28-2003, 04:42 PM
Did you search, find and read the posts I previously made on how to do this?

If you don't want the Dear sir/madame to show in the popup window. Set the style display to none to hide the div(s)

result.document.writeln('<div style="display:none">Dear sir/madam</div>');
result.document.writeln('<div> </div>');
result.document.writeln('<div style="display:none">I would like to order these items.</div>');

I can't help you with the subject problem in MSN since I do not have it to test with. Try removing the space between Order & Form. Try Order%20Form....

.....Willy

Edit: It was suppose to be %20 not &20

loftty
12-29-2003, 06:06 AM
Hello Willy,

The code worked well with the sir/madam par. thanks

I have tried putting in %20 in between Order Form but I still get the same problem. I have sent attached 2 screenshots of what my outlook express looks like and my MSN looks like.
I hope you can help?

Thanks
Loftty

Willy Duitt
12-29-2003, 06:47 AM
I understand but don't know what to tell you.

You can try these changes:
(with and without the &)
result.document.writeln('<scr'+'ipt type="text/javascript">');
result.document.writeln('function mailIt(){paras=document.getElementsByTagName("div");'
+'var msg="";for(i=0;i<paras.length;i++)msg+=paras[i].innerHTML+"\\n";msg=(escape(msg));'
+'var subj="Order Form";'
+'document.MAIL.action="mailto:lofty@hotmail.net?&subject="+subj+"&body="+msg;'
+'document.MAIL.submit();}');
result.document.writeln('</scr'+'ipt>');

Other than that, try a Google Search and see if you can
find anything related to MSN Mailto Subject Line Problems?

.....Willy

loftty
12-29-2003, 08:31 AM
Hello Willy,

I tried your way what you posted with and without the &
but errors kept coming up on the page, Then I tried this way.



+'document.MAIL.action="mailto:lofty@hotmail.net&subject=Order Form&body="+msg;'


and it worked in my MSN.

But now I have trouble with my outlook express it puts everything including the items the user orders into the email address section.

Why is this?

Thanks
Loftty

Willy Duitt
12-29-2003, 09:38 AM
Errors, what errors?
I tested the code and unless you did something wrong there should be no errors.
Although with the & prior to the subject, OE does not display the subject matter.

Plus, you need the querry ? to delimit the mailto: string.

Try adding a bogus bcc field before the subject.

eg:
+'document.MAIL.action="mailto:lofty@hotmail.net?bcc=&subject=Order%20Form&body="+msg;'

I hope you have at least done a search at google or another search engine to see if this is a known MSN problem and if there is a known fix.

I'm running out of guesses here! =:O

.....Willy

loftty
12-29-2003, 10:22 AM
Dear Willy,

I have been doing a search, and im still searching.

But just for piece of mind this is the code I have that you gave me, plus I have also tried adding the bcc=
and I keep getting errors.
into my code but no luck.


function showIt(){
result=window.open('','results','width=650,height=550');
result.document.writeln('<form name="MAIL" method="POST" action="" enctype="text/html">');
result.document.writeln('<div style="display:none">Dear sir/madam</div>');
result.document.writeln('<div> </div>');
result.document.writeln('<div>I would like to order these items.</div>');
result.document.writeln('<div> </div>');
result.document.writeln('<div> </div>');
result.document.writeln(productList);
result.document.writeln('<div> </div>');
result.document.writeln('<div>The total is: £'+runningTotal+'</div>');
result.document.writeln('<div>The total plus VAT is: £'+((1.175*runningTotal)+6)+'</div>');
result.document.writeln('<div> </div>');
result.document.writeln('<div> </div>');
result.document.writeln('<div>Thank You;</div>');
result.document.writeln('<input type="button" value="Submit" onclick="mailIt()">');
result.document.writeln('</form>');
result.document.writeln('<scr'+'ipt type="text/javascript">');
result.document.writeln('function mailIt(){paras=document.getElementsByTagName("div");'
+'var msg="";for(i=0;i<paras.length;i++)msg+=paras[i].innerHTML+"\\n";msg=(escape(msg));'
+'var subj="Order Form";'
+'document.MAIL.action="mailto:lofty@hotmail.net?&subject="+subj+"&body="+msg;'
+'document.MAIL.submit();}');
result.document.writeln('</scr'+'ipt>');


Thanks
Loftty

giz
12-29-2003, 06:38 PM
Make sure you change any &amp; in the URLs to be &amp;amp; instead.

loftty
12-30-2003, 04:38 AM
Dear Giz,

I have attached you the html page that I'm working on,
and the you will see for yourself that it has errors on it.


If you think you know the solution, I would be most pleased.

Thanks
Lol

loftty
12-30-2003, 04:40 AM
Sorry here is the attachement.

Willy Duitt
12-30-2003, 06:32 AM
Originally posted by Willy Duitt
Errors, what errors?
I tested the code and unless you did something wrong
there should be no errors.

Your errors are being thrown because you lost a
closing bracket } when you made the changes.

+'var subj="Order Form";'
+'document.MAIL.action="mailto:lofty@hotmail.net?&subject="+subj+"&body="+msg;'
+'document.MAIL.submit();}');
result.document.writeln('</scr'+'ipt>');
}
//-->
</script>

.....Willy

loftty
12-30-2003, 07:32 AM
Willy,

Sorry you was right,

But In msn I get a question mark at the end of email name, eg, lofty@hotmail.net?.
And in the outlook express I get no subject.

I have now tried putting the bcc= before the &subject part, and everything is ok but with msn I do not get any email address show up.

Why is this?

Thanks agian

Loftty

Willy Duitt
12-30-2003, 07:48 AM
Originally posted by Willy Duitt
Although with the & prior to the subject, OE does not display the subject matter.

Try adding a bogus bcc field before the subject.

eg:
+'document.MAIL.action="mailto:lofty@hotmail.net?bcc=&subject=Order%20Form&body="+msg;'

Did you try the above since you fixed the errors?

I'm sorry, I can not help you with the MSN mailto problem
any further. I do not have MSN to test with, and I am out
of guesses.

.....Willy

Edit: Eieee, you editted your previous post while responding.
I have now tried putting the bcc= before the &subject part,
and everything is ok but with msn I do not get any email address show up.

Try putting a real address in the bcc field.
You'll have to experiment yourself Loftty,
As I said, I do not have MSN and am out of guesses.

.....Willy

loftty
12-30-2003, 08:23 AM
Dear Willy,


I would like to just say Thankyou for your help,

I have got it now.

Thankyou so much

Loftty

Willy Duitt
12-30-2003, 09:12 AM
Originally posted by loftty
Dear Willy,


I would like to just say Thankyou for your help,

I have got it now.

Thankyou so much

Loftty

Please let me know how you resolved the
MSN issue so I know this for the future.

Thank you;
.....Willy

loftty
12-30-2003, 10:29 AM
Hello Willy,

Please let me know how you resolved the
MSN issue so I know this for the future.



result.document.writeln('function mailIt(){paras=document.getElementsByTagName("div");'
+'var msg="";for(i=0;i<paras.length;i++)msg+=paras[i].innerHTML+"\\n";msg=(escape(msg));'
+'var subj="Order Form";'
+'document.MAIL.action="mailto:ben.riches7@ntlworld.com?bcc=ben.riches7@ntlworld.com&subject="+subj+"&body="+msg;'
+'document.MAIL.submit();}');
result.document.writeln('</scr'+'ipt>');


Thanks Again Willy i'm most grateful for your help

Thanks
Loftty

Willy Duitt
12-30-2003, 10:33 AM
Oh, Ok
It looks like the bcc with a real address did do the trick for MSN.
Good to know!

Thanks;
.....Willy