/    Sign up×
Community /Pin to ProfileBookmark

Anyone remember this?

Within the last few days, I looked at a question and response in this forum that I thought was a great technique to use in javascript, but at the time I had no direct use for the techique. Now I have found a use, but I have forgotten the posting.

? I have tried using the search for many combinations of the following, but I cannot locate the posting I saw:

The posting involved the use of a “selection” “option” that contained information that could be “split” using, I think, the “regex” function. What I believed it did was allow the program to use the user selection to “calculate” a “markup” or “modifier” for a calculation in the “form”.

I have searched for all the quoted words in the paragraph above.

For the life of me I cannot locate the posting. Does anyone remember the posting of something like this or have I just started down the road to dementia? 😮

Thanks to anyone with a better memory than me!

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterMar 23.2006 — I don't understand what you mean, was it something like this?
<i>
</i>&lt;option value="user,pass,account"&gt;
Copy linkTweet thisAlerts:
@JMRKERauthorMar 23.2006 — Ultimater,

I don't recall it being associated with accounts or passwords. (but I could be wrong)

I think it was more along the line of:

<i>
</i>&lt;HTML&gt;
...
&lt;select&gt;
&lt;option value="something | somecost"&gt;
&lt;/select&gt;
...
Total = FinalCost(selection.value) * TaxRate;
...


&lt;javascript code&gt;
..
// this is what I 'think' the function used to separate the joined string value
function FinalCost (strvalue) {
var thing = 0;
var cost = 0;
(thing,cost) = strvalue.split(/|/);
// but it may have been an "eval strvalue.regex('|')" or something like it
// this is the part I'm trying to locate in the forum discussion
return cost;
}



This is probably not the code in the original posting, but it is what I was thinking about how to use it when I first read the forum posting. I did not have an acutal use for the posting at that time, just thought it was an interesting concept. Now I want to try it in a script I'm developing.

Thanks for trying.
Copy linkTweet thisAlerts:
@JMRKERauthorMar 23.2006 — Thanks again Ultimater.

I think the last thread you listed is as close as I can remember. At least now I know I'm not as crazy as I might have been. :rolleyes:

While you were looking up all those threaded links, I was busy trying to see if I could re-create my thoughts with some original code. The following code seems to work for my initial purposes. It is the start of a practice simulation where the student would set up their own practice conditions and calculate what the potential income would be for their selections. The current values are entirely fictional and designed only for testing purposes of the concept.

<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;title&gt;PM test&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="./table.css"&gt;
&lt;script language="javascript" type="text/javascript"&gt;
&lt;!--
function Extract(svalue) {
var info = new Array();
info = svalue.split("|");
return info[1];
}
function Calc(tform) {
var Expect = 0;

// Site
Expect = Extract(tform.Location.value);
Expect = Expect * Extract(tform.OfficeSF.value);

// Income
Expect = Expect + parseInt(tform.PtLoad.value) * parseInt(tform.ExamFee.value);

// Expenses
if (tform.Exp1.checked) { Expect = Expect - (Extract(tform.Exp1.value)*100); }
if (tform.Exp2.checked) { Expect = Expect - (Extract(tform.Exp2.value)*100); }
if (tform.Exp3.checked) { Expect = Expect - (Extract(tform.Exp3.value)*100); }
if (tform.Exp4.checked) { Expect = Expect - (Extract(tform.Exp4.value)*100); }
if (tform.Exp5.checked) { Expect = Expect - (Extract(tform.Exp5.value)*100); }
if (tform.Exp6.checked) { Expect = Expect - (Extract(tform.Exp6.value)*100); }
if (tform.Exp7.checked) { Expect = Expect - (Extract(tform.Exp7.value)*100); }
if (tform.Exp8.checked) { Expect = Expect - (Extract(tform.Exp8.value)*100); }
tform.Expectation.value = Expect.toString();
}
// --&gt;
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;form name="PM" onSubmit="javascript:void(0);return false"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td valign="top"&gt;
Site Information:
&lt;p&gt;
Surrounding population:&lt;br&gt;

&lt;select name="Location"&gt;
&lt;option value="|"&gt;&lt;/option&gt;
&lt;option value="Large City | 100"&gt;&amp;gt; 100,000 &lt;/option&gt;
&lt;option value="City | 90"&gt;&amp;gt; 50,000&lt;/option&gt;
&lt;option value="Small | 80"&gt;&amp;gt; 10,000 &lt;/option&gt;
&lt;option value="Town | 70"&gt;&amp;gt; 1,000 &lt;/option&gt;

&lt;option value="Suburban | 60"&gt;&amp;gt; 500 &lt;/option&gt;
&lt;option value="Farm | 40"&gt;&amp;lt 500 &lt;/option&gt;
&lt;option value="Sticks | 10"&gt;&amp;lt 50 &lt;/option&gt;
&lt;/select&gt;&lt;br&gt; within radius of 5 miles.
&lt;p&gt;

Office size:&lt;br&gt;

&lt;select name="OfficeSF"&gt;
&lt;option value="|"&gt;&lt;/option&gt;
&lt;option value="Large|90"&gt;Large (&amp;gt;2000)&lt;/option&gt;
&lt;option value="Medium|70"&gt;Medium (&amp;gt;1000)&lt;/option&gt;
&lt;option value="Small|50"&gt;Small (&amp;gt;500&lt;/option&gt;
&lt;option value="Tiny|30"&gt;Tiny&lt;/option&gt;

&lt;/select&gt;&lt;br&gt; square feet.
&lt;/td&gt;

&lt;td valign="top"&gt;
Income:
&lt;p&gt;
Patient load:&lt;br&gt;
&lt;select name="PtLoad"&gt;
&lt;option value=""&gt;&lt;/option&gt;
&lt;option value="16"&gt;16&lt;/option&gt;
&lt;option value="12"&gt;12&lt;/option&gt;

&lt;option value="8"&gt;8&lt;/option&gt;
&lt;option value="4"&gt;4&lt;/option&gt;
&lt;/select&gt; &lt;br&gt;per day.
&lt;p&gt;

Fees:&lt;br&gt;
&lt;select name="ExamFee"&gt;
&lt;option value=""&gt;&lt;/option&gt;
&lt;option value="75"&gt;75&lt;/option&gt;

&lt;option value="65"&gt;65&lt;/option&gt;
&lt;option value="55"&gt;55&lt;/option&gt;
&lt;option value="45"&gt;45&lt;/option&gt;
&lt;option value="35"&gt;35&lt;/option&gt;
&lt;/select&gt;&lt;br&gt; per exam.
&lt;/td&gt;

&lt;td valign="top"&gt;

Expenses:
&lt;ul&gt;
&lt;li&gt; &lt;input type="checkbox" name="Exp1" value="Rent|10"&gt;Rent
&lt;li&gt; &lt;input type="checkbox" name="Exp2" value="Phone|5"&gt;Phone
&lt;li&gt; &lt;input type="checkbox" name="Exp3" value="Electricity|6"&gt;Electricity
&lt;li&gt; &lt;input type="checkbox" name="Exp4" value="Water|4"&gt;Water
&lt;li&gt; &lt;input type="checkbox" name="Exp5" value="Trash|2"&gt;Trash
&lt;li&gt; &lt;input type="checkbox" name="Exp6" value="Ads|7"&gt;Advertisment
&lt;li&gt; &lt;input type="checkbox" name="Exp7" value="Promo|3"&gt;Promotions
&lt;li&gt; &lt;input type="checkbox" name="Exp8" value="Recall|5"&gt;Recall mailing

&lt;/ul&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;
&lt;button onClick="Calc(this.form)"&gt;Calculate&lt;/button&gt;
Expectations: &lt;input type="text" name="Expectation" value=""&gt;

&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;



The style sheet is optional for the display, but I'm trying out different ideas at the same time. It looks like this:
<i>
</i>table { border-bottom: 1px dotted fuchsia;
border-left: 1px dotted fuchsia }

td { padding: 11px 20px 20px 11px;
border-top: 1px dotted fuchsia;
border-right: 1px dotted fuchsia }

ul { margin-top: 10px;
margin-bottom: 10px;
margin-left: 0;
padding-left: 1em }

li { margin-bottom: 10px }


What will be added in the future will be some randomized parameters that will change the outcome by virtue of some additional variable conditions, for example: bad weather, changes to economic conditions in the area, sickness, working days per week, etc.

I thank you very much for the time and effort you put into my ramblings. ?
×

Success!

Help @JMRKER spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...