Whenever I do a search WITHOUT selecting the "Match Any" radiobox, I get a FAILED SEARCH page that includes the dollar sign [$] within the price fields. If you try another search, those dollar signs screw up the second search and add another dollar sign!......how do I keep the $ sign from showing up in the text boxes?? Thanks!
Sep 7, 2000, 8:26 PM
Enthusiast / Moderator (885 posts)
Sep 7, 2000, 8:26 PM
Post #2 of 13
Views: 3779
Sep 8, 2000, 8:21 AM
Veteran / Moderator (3034 posts)
Sep 8, 2000, 8:21 AM
Post #4 of 13
Views: 3777
Bernardo:
You will most likely want to remove the dollar sign and comma from your database entries and then add them back for only displaying purposes.
You will find various thread references which will show you how to do this in the FAQ noted below.
Look under "Syntax".
Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
You will most likely want to remove the dollar sign and comma from your database entries and then add them back for only displaying purposes.
You will find various thread references which will show you how to do this in the FAQ noted below.
Look under "Syntax".
Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Sep 8, 2000, 9:39 AM
Enthusiast / Moderator (885 posts)
Sep 8, 2000, 9:39 AM
Post #5 of 13
Views: 3736
Hi Lois! You know, I spent a substantial amount of time at your online FAQ's and searching in the forums here at GT. I couldn't find anything which could resolve Bernard's problem. I may be misunderstanding the problem though!
What I'm seeing in his file and his inquiry -
He's using VALUE="\$$rec{'List Price'}" in his sub html_record_form routine.
Since this same form is being used to also add/edit a record, wouldn't this place a $ sign in the actual record upon editing and then add another when viewing again? It seems like this method would cause replication of the $ sign in there.
It appears that he may not have a regex for currency formatting in his db config (sorry, tried finding it and couldn't locate the syntax) so he is doing it thru page displays.
Bernardo - Would you mind posting your db.cfg field definition for 'List Price' and posting an example of what this entry actually looks like in your default.db file?
I'm learning, too! I'd like to figure out what is happening here :)
What I'm seeing in his file and his inquiry -
He's using VALUE="\$$rec{'List Price'}" in his sub html_record_form routine.
Since this same form is being used to also add/edit a record, wouldn't this place a $ sign in the actual record upon editing and then add another when viewing again? It seems like this method would cause replication of the $ sign in there.
It appears that he may not have a regex for currency formatting in his db config (sorry, tried finding it and couldn't locate the syntax) so he is doing it thru page displays.
Bernardo - Would you mind posting your db.cfg field definition for 'List Price' and posting an example of what this entry actually looks like in your default.db file?
I'm learning, too! I'd like to figure out what is happening here :)
Sep 8, 2000, 1:01 PM
Novice (11 posts)
Sep 8, 2000, 1:01 PM
Post #7 of 13
Views: 3741
Thanks Karen, here's the info:
Field definition:
'Our Price' => [10, 'numer', 20, 255, 0, '', ''],
Database entry ("17100" and "6500" are prices):
Olympus|GIF-XQ20|Multipurpose Gastroscope|Gastroenterology|Fiberscopes|Gastroscopes|9.8mm/2.8mm channel|103cm, 100 deg|210U/90D, 100 R&L|17100|6500|Call|14
I thought it was very strange that I needed to do all these mods to display prices with a dollar dign and comma...I hope you can help......thanks again!
Field definition:
'Our Price' => [10, 'numer', 20, 255, 0, '', ''],
Database entry ("17100" and "6500" are prices):
Olympus|GIF-XQ20|Multipurpose Gastroscope|Gastroenterology|Fiberscopes|Gastroscopes|9.8mm/2.8mm channel|103cm, 100 deg|210U/90D, 100 R&L|17100|6500|Call|14
I thought it was very strange that I needed to do all these mods to display prices with a dollar dign and comma...I hope you can help......thanks again!
Sep 10, 2000, 4:58 PM
Enthusiast / Moderator (885 posts)
Sep 10, 2000, 4:58 PM
Post #8 of 13
Views: 3740
Bernardo, it took some time - believe me I have scoured these boards and perl.com - jerrysu was able to provide the correct regex for currency after I posted a request in the perl/cgi forum. (Thank you Jerry!)
I am not sure how much changing in other areas of your files would be required but, you may want to add the Regular Expression (regex) for currency as a required format in your .cfg file.
'Our Price' => [10, 'numer', 20, 255, 0, '', ''],
Would become
By adding a "default display" in the field ($0.00) you let viewers know how the entry should be made. If commas could be a problem, you could add a small text area near the input field to give an example of the format with commas. Example: $12,123.45
The regex will require a $ sign, no problem since you'll have that in your default display and follow up with 0-3 numbers, 1-3 numbers (assumes everything is more than $1 in cost), with a decimal point followed by 2 numbers.
With the other changes your db files would need, you may want to give some thought on whether to make the change - It has just been driving me nuts to not be able to find the regex for currency again after I had seen it in here before.
<wink>
I am not sure how much changing in other areas of your files would be required but, you may want to add the Regular Expression (regex) for currency as a required format in your .cfg file.
'Our Price' => [10, 'numer', 20, 255, 0, '', ''],
Would become
Code:
'Our Price' => [10,'numer',20,255,0,'$0.00','^\$\d{0,3},\d{1,3}\.?\d{2}$'],The regex will require a $ sign, no problem since you'll have that in your default display and follow up with 0-3 numbers, 1-3 numbers (assumes everything is more than $1 in cost), with a decimal point followed by 2 numbers.
With the other changes your db files would need, you may want to give some thought on whether to make the change - It has just been driving me nuts to not be able to find the regex for currency again after I had seen it in here before.
<wink>
Sep 11, 2000, 8:44 AM
Veteran / Moderator (3034 posts)
Sep 11, 2000, 8:44 AM
Post #9 of 13
Views: 3733
Try the following and see if this solves your problem with the commas, and dollar signs. Adding these codes should remove any dollar signs and commas from the field entries and then add them back in for the display.
In your .CFG file define your field as:
'Our Price' => [10, 'alpha', 20, 30, 0, '', ''],
In your DB.CGI:
In sub add_record
before: $status = &validate_record;
add:
$in{'Our Price'} =~ s/,//g; ### remove comma from entry
HTML.PL:
In sub html_record
After: my (%rec) = @_;
Add:
1 while $rec{'Our Price'} =~ s/(\d)(\d{3})\b/$1,$2/; ## add commas back into price
$rec{'Our Price'} = "\$" . $rec{'Our Price'}; ### adds dollar sign back into price field
If you are using the short/long mod you may also want to add this:
In sub html_record_long
1 while $rec{'Our Price'} =~ s/(\d)(\d{3})\b/$1,$2/; ## add commas back into price
$rec{'Our Price'} = "\$" . $rec{'Our Price'}; ### adds dollar sign back into price field
If you are going to be using price range searches, then this would be the format needed for that also. There are several thread references dealing with price range searches which contain the coding provided above.
If you think people would be adding a dollar sign when entering the field value in your db.cgi file you could also add:
$in{'Our Price'} =~ s/\$//g; ### remove dollar sign from entry
Hope this will provide the solution you need.
Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
In your .CFG file define your field as:
'Our Price' => [10, 'alpha', 20, 30, 0, '', ''],
In your DB.CGI:
In sub add_record
before: $status = &validate_record;
add:
$in{'Our Price'} =~ s/,//g; ### remove comma from entry
HTML.PL:
In sub html_record
After: my (%rec) = @_;
Add:
1 while $rec{'Our Price'} =~ s/(\d)(\d{3})\b/$1,$2/; ## add commas back into price
$rec{'Our Price'} = "\$" . $rec{'Our Price'}; ### adds dollar sign back into price field
If you are using the short/long mod you may also want to add this:
In sub html_record_long
1 while $rec{'Our Price'} =~ s/(\d)(\d{3})\b/$1,$2/; ## add commas back into price
$rec{'Our Price'} = "\$" . $rec{'Our Price'}; ### adds dollar sign back into price field
If you are going to be using price range searches, then this would be the format needed for that also. There are several thread references dealing with price range searches which contain the coding provided above.
If you think people would be adding a dollar sign when entering the field value in your db.cgi file you could also add:
$in{'Our Price'} =~ s/\$//g; ### remove dollar sign from entry
Hope this will provide the solution you need.
Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Sep 11, 2000, 10:32 AM
Novice (11 posts)
Sep 11, 2000, 10:32 AM
Post #10 of 13
Views: 3714
Karen: thank you so much for your efforts....I made the changes and everything works fine. However, I'm back to the original position of having the prices display as 17,100 and not $17,100. It's not a huge deal...at least the searches work now. Thanks again! Let me know if you find a cure-all.
Sep 11, 2000, 10:55 AM
Enthusiast / Moderator (885 posts)
Sep 11, 2000, 10:55 AM
Post #11 of 13
Views: 3726
Hello Bernardo, making progress somewhat then <wink>
If you could resave your files and make them available again, I could lend another pair of eyes to help look things over again. Likely there is an entry such as the one LoisC referrenced, $in{'Our Price'} =~ s/\$//g; in the cgi somewhere.
If you could resave your files and make them available again, I could lend another pair of eyes to help look things over again. Likely there is an entry such as the one LoisC referrenced, $in{'Our Price'} =~ s/\$//g; in the cgi somewhere.
Sep 12, 2000, 3:00 PM
Enthusiast / Moderator (885 posts)
Sep 12, 2000, 3:00 PM
Post #13 of 13
Views: 3715
Hi Bernardo, I suspect the conflict is going to be somehow related to the modifications made earlier to get the currency output but I'm not sure what needs to be changed to correct the problem. These entires:
$rec{'Our Price'} = sprintf ("%.2f", $rec{'Our Price'});
1 while $rec{'Our Price'} =~ s/(\d)(\d{3})\b/$1,$2/; if ($rec{'Our Price'}) {
I'll keep looking for an answer :) In the meantime, we can hope that Mark, Lois or one of the other more knowledgeable folks will be able to view your files and spot where the correction needs to be made.
BTW - How many "product" entries do you have in your db? Would it be feasible for you to download and check the actual db? Try adding a $ sign and the correct comma/decimal point entries into the Our Price field (if not already there) and see what happens when you try to view the record again.
$rec{'Our Price'} = sprintf ("%.2f", $rec{'Our Price'});
1 while $rec{'Our Price'} =~ s/(\d)(\d{3})\b/$1,$2/; if ($rec{'Our Price'}) {
I'll keep looking for an answer :) In the meantime, we can hope that Mark, Lois or one of the other more knowledgeable folks will be able to view your files and spot where the correction needs to be made.
BTW - How many "product" entries do you have in your db? Would it be feasible for you to download and check the actual db? Try adding a $ sign and the correct comma/decimal point entries into the Our Price field (if not already there) and see what happens when you try to view the record again.