Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

All I want is a "yes man"! 1

Status
Not open for further replies.

EdwardMartinIII

Technical User
Sep 17, 2002
1,655
US
Here's a goofy little project. I want a "yes man".

Here's my (way stripped down) JS file:

Code:
function OhAbsolutely(Argument)
  {
    var YesString = "Oh, Absolutely!"
    Argument += "\n\n" + YesString + "\n\n"
    return Argument;
  }

And here's the HTML page that calls it:

Code:
<!DOCTYPE html 
     PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;
     &quot;[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;>[/URL]

<html xmlns=&quot;[URL unfurl="true"]http://www.w3.org/1999/xhtml&quot;[/URL] xml:lang=&quot;en&quot; lang=&quot;en&quot;>
  <head>
    <meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;></meta>
    <title>JavaScript Sample</title>
    <script src=&quot;Sample.js&quot; type=&quot;text/javascript&quot;></script>
  </head>
  <body>
    <form name=&quot;MainForm&quot; action=&quot;&quot;>
      <p>Please start by describing your business issue below</p>
      <p>Press <input type=&quot;button&quot; value=&quot;Respond&quot; id=&quot;Analyze&quot; onclick=&quot;document.MainForm.Texty.value=OhAbsolutely(document.MainForm.Texty.value);document.MainForm.Texty.focus();return true;&quot;></input> for a response.</p>
      <textarea rows=&quot;30&quot; cols=&quot;50&quot; name=&quot;Texty&quot; id=&quot;Texty&quot;></textarea>
    </form>
  </body>
</html>

In Mozilla, after you click the button, it places the cursor at the bottom of the text area, which is where I want it (ready to ask the next &quot;burning question&quot;, but in IE, it places it at the end of the text line, completely ignoring (it seems) the two extra line returns.

My goal is to have the cursor drop to the bottom of the window -- the end of the string it currently contains.

Any suggestions?

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Okay, changing the JS function to actually include a string at the end seemed to help:

Code:
function OhAbsolutely(Argument)
  {
    var YesString = &quot;Oh, Absolutely!&quot;
    Argument += &quot;\n\n&quot; + YesString + &quot;\n\n&quot; + &quot;please continue: &quot;
    return Argument;
  }

Yeah, once I add a random phrase picker and about thirty of these, it'll be a very uplifting version of Eliza.

laughing,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
I'm so self-contained!

Here's the revised function:

Code:
function OhAbsolutely(Argument)
  {
    var ResponseArray = new Array();
    ResponseArray[0] = &quot;Oh, Absolutely!&quot;;
    ResponseArray[1] = &quot;Seems obvious to me.&quot;;
    ResponseArray[2] = &quot;Of course.&quot;;
    ResponseArray[3] = &quot;How come no one else can see this as clearly?&quot;;
    ResponseArray[4] = &quot;I've always said you were a genius.&quot;;
    ResponseArray[5] = &quot;Makes sense.&quot;;
    ResponseArray[6] = &quot;Superlative!&quot;;
    ResponseArray[7] = &quot;Yer preachin' to the choir.&quot;;
    ResponseArray[8] = &quot;I completely agree.&quot;;
    ResponseArray[9] = &quot;Just tell me what you want -- I totally believe in this project!&quot;;
    ResponseArray[10] = &quot;Yep.&quot;;
    var Indexer = Math.floor(Math.random() * ResponseArray.length);
    var YesString = ResponseArray[Indexer];
    Argument += &quot;\n\n&quot; + YesString + &quot;\n\n&quot; + &quot;Please continue: &quot;
    return Argument;
  }

So, please share any other &quot;yes&quot; phrases I can add to this. I'm trying to electronically replicate a simpering Junior Account Exec (which is why I'm not bothering with Artificial Intelligence), you see... [lol]

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
I'm so self-contained!

Here's the revised function:

Code:
function OhAbsolutely(Argument)
  {
    var ResponseArray = new Array();
    ResponseArray[0] = &quot;Oh, Absolutely!&quot;;
    ResponseArray[1] = &quot;Seems obvious to me.&quot;;
    ResponseArray[2] = &quot;Of course.&quot;;
    ResponseArray[3] = &quot;How come no one else can see this as clearly?&quot;;
    ResponseArray[4] = &quot;I've always said you were a genius.&quot;;
    ResponseArray[5] = &quot;Makes sense.&quot;;
    ResponseArray[6] = &quot;Superlative!&quot;;
    ResponseArray[7] = &quot;Yer preachin' to the choir.&quot;;
    ResponseArray[8] = &quot;I completely agree.&quot;;
    ResponseArray[9] = &quot;Just tell me what you want -- I totally believe in this project!&quot;;
    ResponseArray[10] = &quot;Yep.&quot;;
    var Indexer = Math.floor(Math.random() * ResponseArray.length);
    var YesString = ResponseArray[Indexer];
    Argument += &quot;\n\n&quot; + YesString + &quot;\n\n&quot; + &quot;Please continue: &quot;
    return Argument;
  }

So, please share any other &quot;yes&quot; phrases I can add to this. I'm trying to electronically replicate a simpering Junior Account Exec (which is why I'm not bothering with Artificial Intelligence), you see... [lol]

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Edward,

I had a similiar problem when appending new lines at the end of a string. I found that simply putting a space at the end did the trick (which is essentially what you've done with the &quot;please continue: &quot; phrase.

As for other phrases how about these off the top of my head:)

Wow! I have so much to learn from you!
You are so self contained! ;)
Give yourself a star!

And perhaps you should since you answered your own questions!
 
Ack, sorry about the double-post.

I think answering my own question was sufficient reward for my already over-fed ego. Giving myself a star would be gratuitous.

If it were even possible.

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Hi Edward
&quot;Affirmative&quot;
&quot;Confirmation given&quot;
&quot;Certainly&quot;
&quot;Sure&quot;
&quot;No problem&quot;
&quot;I'm totally on board&quot;
&quot;What a perfect suggestion, would you like to come to dinner? Eat my food? Drink my wine? Sleep with my wife? Take my car?&quot;

btw don't you think &quot;Argument&quot; may be the wrong name for your argument, given that every answer is yes? [lol]

Hope I helped / Thanks for helping
if ((Math.abs(x)<10&&Math.abs(y)<10) && (((parseInt(Math.abs(x).toString()+Math.abs(y).toString())-Math.abs(x)-Math.abs(y))%9)!=0)) {alert(&quot;I'm a monkey's uncle&quot;);}
 
HellTel,

Thanks for writing! Those were funny, and they inspired me to a few others, too.

I like the idea that I'm using &quot;Argument&quot; because it'll convince whoever reads the code that they actually won something.

Here's the revised function, with 30 different affirmations (only 30?! Surely there's got to be more positive biz-speek than that!). Oh, this is way too much fun. This little gem's gotta go on the personal website...

Code:
function OhAbsolutely(Argument)
  {
    var ResponseArray = new Array();
    ResponseArray[0] = &quot;Oh, Absolutely!&quot;;
    ResponseArray[1] = &quot;Seems obvious to me.&quot;;
    ResponseArray[2] = &quot;Of course.&quot;;
    ResponseArray[3] = &quot;How come no one else can see this as clearly?&quot;;
    ResponseArray[4] = &quot;I've always said you were a genius.&quot;;
    ResponseArray[5] = &quot;Makes sense.&quot;;
    ResponseArray[6] = &quot;Superlative!&quot;;
    ResponseArray[7] = &quot;Yer preachin' to the choir.&quot;;
    ResponseArray[8] = &quot;I completely agree.&quot;;
    ResponseArray[9] = &quot;Just tell me what you want -- I totally believe in this project!&quot;;
    ResponseArray[10] = &quot;Yep.&quot;;
    ResponseArray[11] = &quot;I have so much to learn from you!&quot;;
    ResponseArray[12] = &quot;Wow.&quot;;
    ResponseArray[13] = &quot;That idea deserves a star for sure.&quot;;
    ResponseArray[14] = &quot;Seems pretty self-contained to me.&quot;;
    ResponseArray[15] = &quot;Seems pretty straightforward to me.&quot;;
    ResponseArray[16] = &quot;I completely understand.&quot;;
    ResponseArray[17] = &quot;Affirmative!&quot;;
    ResponseArray[18] = &quot;Certainly!&quot;;
    ResponseArray[19] = &quot;Sure!&quot;;
    ResponseArray[20] = &quot;No problem!&quot;;
    ResponseArray[21] = &quot;I'm totally on board with that.&quot;;
    ResponseArray[22] = &quot;You're the man!&quot;;
    ResponseArray[23] = &quot;How insightful!&quot;;
    ResponseArray[24] = &quot;How Impactful!&quot;;
    ResponseArray[25] = &quot;I am in awe of you.&quot;;
    ResponseArray[26] = &quot;I cannot imagine a better idea than that.&quot;;
    ResponseArray[27] = &quot;I am not worthy.&quot;;
    ResponseArray[28] = &quot;I'm proud to be a member of this team.&quot;;
    ResponseArray[29] = &quot;Now THAT is good for the company!&quot;;
    ResponseArray[30] = &quot;I'm glad you're on OUR side!&quot;;
    var Indexer = Math.floor(Math.random() * ResponseArray.length);
    var YesString = ResponseArray[Indexer];
    Argument += &quot;\n\n&quot; + YesString + &quot;\n\n&quot; + &quot;Please continue: &quot;
    return Argument;
  }

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
&quot;Sounds like a no-brainer.&quot;
&quot;We're on the same page.&quot;


=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top