PDA

View Full Version : Please help me...just a little way to finish..



marry07
May 10th, 2005, 07:13 AM
Dear All Expert,

I am doing an assignment for my study. It almost finish and it is work. However, there is something missing in formula a bit. But I am stack. I really need your help. If you try, if you play with QTY, it will be the same and the total will count only 1 QTY....Please, anyone could help me for this..???..I attach my HTML file as a TXT file for your review, if you could...

Thank you very much for your kind help..

:) Marry

WMJB
May 10th, 2005, 07:23 AM
try this line:


form.cpu_price.value = parseInt(form.cpu.options[form.cpu.selectedIndex].value) * parseInt(form.cpu_qty.options[form.cpu_qty.selectedIndex].value);

instead of:


form.cpu_price.value = parseInt(form.cpu.value) * parseInt(form.cpu_qty.value);

that should be your problem i hope.

glenngv
May 10th, 2005, 08:27 AM
try this line:


form.cpu_price.value = parseInt(form.cpu.options[form.cpu.selectedIndex].value) * parseInt(form.cpu_qty.options[form.cpu_qty.selectedIndex].value);

instead of:


form.cpu_price.value = parseInt(form.cpu.value) * parseInt(form.cpu_qty.value);

that should be your problem i hope.
Modern browsers already allows select.value but I also prefer that long method.

But the main cause of problem is that a text field and function name are the same (total_price). Try to avoid naming the function the same as the field name to avoid unexpected error. There are also other errors, the passed parameter from the onchange handler of the Quantity combobox is wrong. And also the selected quantity is not included in the formula to get the total. See the attachment. I renamed the total_price() function to fill_total_price().

marry07
May 10th, 2005, 09:03 AM
Dear Glen,

It works on the total but if you change your QTY your price would not change...Just please try to change QTY and see your right field as a cpu_price..it wont changed...Please help me :)

I re-attach your modified text.

Thank you,

Marry

glenngv
May 10th, 2005, 09:11 AM
When the quantity is changed, the total price changes. I multiplied the selected quantity to the selected CPU.

var tot_price = parseFloat(form.cpu.value*form.cpu_qty.value) + parseFloat(form.motherboard.value) + parseFloat(form.monitor.value);

marry07
May 10th, 2005, 09:26 AM
Dear Glen,

Yes, the total price changed. But, the CPU Price did not changed. Note: CPU Price is the text field next to Qty text field.

That is the current problem...Would you please fix for me in order the CPU Price also works...??? :)

Thanks very much,

Marry

marry07
May 10th, 2005, 09:26 AM
Dear Glen,

Yes, the total price changed. But, the CPU Price did not changed. Note: CPU Price is the text field next to Qty text field.

That is the current problem...Would you please fix for me in order the CPU Price also works...??? :)

Thanks very much,

Merry

glenngv
May 10th, 2005, 09:43 AM
Simply call fill_cpu_price() function since in that function the cpu price and total price are both calculated.

<select name="cpu_qty" onChange="fill_cpu_price(this.form)">

marry07
May 10th, 2005, 09:51 AM
Thank you very much for your kind help Glen...Now, it works...One more thing is, do you know how, if you click "Generate Report", it will open new page for report right...my question is, do you know 'How to send my report to my email?' if I add one button for "Confirm" and "Cancel". Confirm button it means, when you click "Confirm" , the form will be sent to my email address....Would you mind please if giving for that code for me OR if you have very good clear explanation URL address..???

Thank you very much,

Marry

glenngv
May 10th, 2005, 10:05 AM
You need a server-side language (ASP, PHP, etc...) to have the form automatically mailed to you. What server-side language your host supports?

marry07
May 10th, 2005, 02:33 PM
Dear Glen,

Honestly, I dont have server side language yet. However, once I registered with host server company, I will email to you...is it alright if I have your email please..???.....Anyway, which one the easiest language for dummies people...???ASP or PHP..???...Is there any sample codes for what I am asking to you please..???

Thank you very much..

Marry

glenngv
May 10th, 2005, 02:41 PM
Just post your problems here and I'm sure many people here are going to help you.

marry07
May 10th, 2005, 05:29 PM
Hi all expert,

I really confuse...when I run this codes and click on "Generate Report", it will open new window and it will calculate each item...However, it wont write total...Anyone could help me please in order to write total please..???...

Thank you very much,

Marry

Note: I attach this file as txt for your review...This is for my assignment...Many thanks...

glenngv
May 11th, 2005, 02:53 AM
Remove the var keyword in the fill_total_price() function. I was the one who put that because I didn't know that tot_price is supposed to be a global variable.

marry07
May 11th, 2005, 12:30 PM
Hi all expert,

Anyone could help me please...????...

How to do this (guidance, the same sample or help):

"When I click "Generate Form", it will display a report about all information that has been selected by users with nice table and border please..."....Any one can help me please how to do this..???

I attach updated files for your review or adjustment....

Thanks so much,

Marry :)

marry07
May 12th, 2005, 12:55 AM
Dear all expert,

Please help me for creating report ready to print...(please see my previous posting for further explanation and file attachment)..

Many thanks,

Marry :(

glenngv
May 12th, 2005, 03:12 AM
You were able to do the report for some of the fields, so you can do the same with other fields.

marry07
May 12th, 2005, 08:27 AM
But Glen, it is totaly different...just try click "Generate Form" and it silly report..even I could not put the QTY in....Please and please help me OR at least give me one example/reference or anything...

Thanks very much,

Marry

marry07
May 12th, 2005, 09:58 AM
I mean, I am stack with some formula as follow :

At the moment, if I click "Generate Report", there are four title of reports: "Parts", "Descriptions", "Quantity Ordered" and "Price". However, after I click at "Generate Report" currently only appeared "Parts" descriptions and "Price" information....I dont know how to show,I don write/formula for Item Selected Anyone and also I dont know how to show/write for "Qty" selected. Anyone knows and could help me please how to write item selected and quanity selected as a report..?????

Herewith I attach my work for my assignment just for your review....

Thanks verymuch for your help..

Marry :)

glenngv
May 12th, 2005, 11:16 AM
Try this:


var report = window.open("","quote");
...
report.document.write("<td>CPU</td><td>"+form.cpu.options[form.cpu.selectedIndex].text+"</td><td>"+form.cpu_qty.value+"</td><td>$&nbsp;" + form.cpu.value*form.cpu_qty.value + "</td>");
...
...
report.document.write("</table>");
report.document.close();
report.focus();
Actually, the cross-browser way to get the value of the selected item is:

form.cpu.options[form.cpu.selectedIndex].value

but modern browsers already supports form.cpu.value. AFAIK, only NS4 doesn't support the shortcut method.

marry07
May 12th, 2005, 03:04 PM
Thanks very much for your help...!!!... :thumbsup:

All works now...!!!....I am very happy..!!!...Can I ask again please???...because, all are done BUT the report is not good looking...they are messy and disorganize...Do you know how to create a nice table and border please in this case..???..so, the report status page is well organized..??? :) Because, I tried with for example: document.report.write("<table border="0" cellspacing="5" cellpadding="5"); and so on follow the HTML language, it wont work...Do you have any idea how in order how to work please???...My point is, how to make it table, border and giving color text..????...

Thanks vey much for your kind help and fully useful assistant...Herewith, I attach my updated TXT file...

Marry

glenngv
May 13th, 2005, 02:47 AM
You need to escape the quotes to include them in the string.

document.report.write("<table border=\"0\" cellspacing=\"5\" cellpadding=\"5\"");

But you can use single quotes to delimit your javascript strings so that you can easily use double quotes without escaping them.

document.report.write('<table border="0" cellspacing="5" cellpadding="5"');


BTW, you need to initialize the global variable tot_price to 0 to avoid error when Generate button is clicked without selecting anything in the select boxes.

var tot_price = 0;

Single Paradox
May 13th, 2005, 03:18 AM
Might I add that if you select nothing at all, an error comes up, lol, plus, on the newly generated page, the Descriptions, Quantity Ordered, Price, and so on isn't lined up all the way with everything else. You have quite a bit &nbsp; 's there too, maybe instead try using css text-aligning? Sorry if it's not what you are looking for, but just some things I noticed.

glenngv
May 13th, 2005, 04:15 AM
Might I add that if you select nothing at all, an error comes up
That's what I was talking about with the variable initialization fix I suggested.

marry07
May 13th, 2005, 01:59 PM
Hi Glen,

I just follow your inputs..however, please try at my attachment...when I click "Generate Report", it come up a report that the Qty Ordered is hangin around in the wrong place...Please have a look if you have times...I dont know what is wrong with this code......I put the code right but the outcome different...

Thank you very much for your kind helps and assistance...

Marry :)

marry07
May 15th, 2005, 03:17 AM
help me please...???

glenngv
May 16th, 2005, 03:20 AM
You missed the opening td tag.

<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>Descriptions</b></td><td>&nbsp;&nbsp;<b>Qty Ordered</b></td>

marry07
May 16th, 2005, 02:22 PM
Hi,

Thanks a lot for your kind help and assistance...Might be, this is my last questions....What codes in the report produced by "Generate Report" to provide these following command:

After I clicked "General Report", it will show all selected items, qty and prices which is already works....However, what codes below the report to provide "Confirm" button that will send this report to my email address, and "Print" button to print this report please...???

Thank you very much,

Marry :)

marry07
May 17th, 2005, 02:29 AM
Please help me...

glenngv
May 17th, 2005, 03:17 AM
As I said in your other thread, you need a server-side language to automatically send form data to email without using mail client. For printing the report, you will just call windowObject.print() method. Where do you want to put the button, in the main page beside the [Generate Report] button or in the report itself?

marry07
May 17th, 2005, 05:46 AM
Hi,

Thanks for your reply...According to "Printer" command, I wanna do this in the report form (what codes please), below all report. Additionally, according to server side server, do you have any idea about the best reference for automatic email for beginner please...???

Thanks very much,

Marry

marry07
May 18th, 2005, 04:41 PM
Hi,

Please help me....

glenngv
May 19th, 2005, 04:17 AM
function generate_report(form)
{
var report = window.open("","quote");
report.document.write('<html><head><title>Report</title><style type="text/css">@media print {\n.displayOnly{display: none;}\n}</style></head><body>');
report.document.write("<form>");
report.document.write('<table border="1" cellspacing="5" cellpadding="5">');

...

report.document.write("</table>");
report.document.write('<input type="button" value="Print" onclick="window.print();" class="displayOnly" />');
report.document.write("</form></body></html>");
report.document.close();
report.focus();
}
Regarding the mail problem, tell us what server-side language your host supports. ASP, PHP or what? Google "asp mail" or "php mail" and you'll get many results.

marry07
May 19th, 2005, 07:05 AM
Thanks for your reply.

I use PHP.

Thanks again,

Marry