Need help with Javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tha Guardians
    MCDC 2011
    • Nov 2006
    • 1680

    #1

    Need help with Javascript

    I haven't messed with Javascript or VBScript in a long time.
    I'm trying to make a page with a text field and button that will translate Pig Latin to Pig Latin.

    I'm pretty sure this can be done using only Javascript.

    Anyway, it should work like this:

    1.) do you speak pig latin?
    2.) oday ouyay peaksay igpay atinlay?
    3.) dayoay uyayoay eaksaypay gpayiay tinlayaay?
    4.) ayoayday yayoayuay aksaypayeak payiaygay inlayaaytay?

    Originally posted by sonic-fast-fingers
    can someone clarrify what QFT means my friend told me its quit ****ing talking, but im not 100 percent sure

    Originally posted by Synthlight
    I need a car that drives itself completely automated and I want it for free and it needs infinite gas mileage.

    Cheers,

    Synthlight
  • Izzy
    Snek
    FFR Simfile Author
    • Jan 2003
    • 9195

    #2
    Re: Need help with Javascript

    I could do it in C#. If its syntax you are looking for I have no idea. If it pseudo code I could probably help.

    Comment

    • tha Guardians
      MCDC 2011
      • Nov 2006
      • 1680

      #3
      Re: Need help with Javascript

      I would like to see it done in any language, but I'm looking for it in Javascript.

      10,000 creds to someone that comes up with this.

      Originally posted by sonic-fast-fingers
      can someone clarrify what QFT means my friend told me its quit ****ing talking, but im not 100 percent sure

      Originally posted by Synthlight
      I need a car that drives itself completely automated and I want it for free and it needs infinite gas mileage.

      Cheers,

      Synthlight

      Comment

      • Izzy
        Snek
        FFR Simfile Author
        • Jan 2003
        • 9195

        #4
        Re: Need help with Javascript

        Well let me just explain how I think it should be done.

        First use delimiters to seperate every word by a space and sort them into an array. Use some kind of substring method to take the first character and move it to the end of the word depending on the length of the word. Then for every word in the array just ad "ay" at the end. Then print them out using a loop to go through the array.

        Comment

        • tha Guardians
          MCDC 2011
          • Nov 2006
          • 1680

          #5
          Re: Need help with Javascript

          Yes, but I don't want a loop or array. I want each function to be called on demand via a submit button.

          Originally posted by sonic-fast-fingers
          can someone clarrify what QFT means my friend told me its quit ****ing talking, but im not 100 percent sure

          Originally posted by Synthlight
          I need a car that drives itself completely automated and I want it for free and it needs infinite gas mileage.

          Cheers,

          Synthlight

          Comment

          • Izzy
            Snek
            FFR Simfile Author
            • Jan 2003
            • 9195

            #6
            Re: Need help with Javascript

            Why can't it do that with a submit button? It could just keep refreshing the text box you entered the original word in to be what the outcome is. Then spamming the submit button would further convert it into pig latin.

            Comment

            • tha Guardians
              MCDC 2011
              • Nov 2006
              • 1680

              #7
              Re: Need help with Javascript

              Yeah, I guess that works. I just need the function to be called.
              Javascript gives me brainpain

              Okay, so the array isn't the part that's bugging me.
              The part that's bugging me is retrieving strings from a text field and writing it to the page.

              Any help there?

              Originally posted by sonic-fast-fingers
              can someone clarrify what QFT means my friend told me its quit ****ing talking, but im not 100 percent sure

              Originally posted by Synthlight
              I need a car that drives itself completely automated and I want it for free and it needs infinite gas mileage.

              Cheers,

              Synthlight

              Comment

              • Squeek
                let it snow~
                • Jan 2004
                • 14444

                #8
                Re: Need help with Javascript

                I was all ready to write up some code for this when I had a brain wave.

                Surely someone else has written a Java program for pig latin, correct?

                http://www.google.com/search?q=java+pig+latin

                Oh hey, they have.

                Comment

                • Izzy
                  Snek
                  FFR Simfile Author
                  • Jan 2003
                  • 9195

                  #9
                  Re: Need help with Javascript

                  Code:
                  using System;
                  using System.Collections.Generic;
                  using System.ComponentModel;
                  using System.Data;
                  using System.Drawing;
                  using System.Linq;
                  using System.Text;
                  using System.Windows.Forms;
                  
                  namespace WindowsFormsApplication1
                  {
                      
                      public partial class PigLatin : Form
                      {
                          public PigLatin()
                          {
                              InitializeComponent();
                               
                          }
                  
                          private void submit_Click(object sender, EventArgs e)
                          {
                              string temp = "";
                              string word = textBox.Text;
                  
                                  char[] delim = { ' ' };
                                  string[] stuff = word.Split(delim);
                  
                                  for (int i = 0; i < stuff.Length; i++){
                                  temp = stuff[i];
                                  string letter = temp.Substring(0, 1);
                                  string part = temp.Substring(1, temp.Length - 1);
                                  stuff[i] = part + letter + "ay";
                  
                                     
                                 }
                  
                                 textBox.Text = "";
                  
                                  for (int k = 0; k > stuff.Length; k++)
                                  {
                  
                                      textBox.Text = textBox.Text + stuff[k];
                                      textBox.Refresh();
                                  }
                  
                              
                          }
                  
                          private void textBox_TextChanged(object sender, EventArgs e)
                          {
                  
                          }
                  
                          private void PigLatin_Load(object sender, EventArgs e)
                          {
                  
                          }
                      }
                  }
                  This is what I came up with. For some reason it doesn't do anything and I'm to lazy to figure out why. It should work though.
                  Last edited by Izzy; 06-26-2009, 01:00 AM.

                  Comment

                  • tha Guardians
                    MCDC 2011
                    • Nov 2006
                    • 1680

                    #10
                    Re: Need help with Javascript

                    Well I'll be damned.
                    I'm look for Javascript, not Java, but I didn't even think of Google.

                    I stumbled across this site.
                    It's a little more advanced than what I'm going for, but it works great. Now if I can cipher through the code and make it rewrite to it's own text field then this should be easy.

                    Edit:

                    Izzy, if you can get that thing working completely and just send me a link or a copy of the source code I'll throw an extra 10k on top.
                    Last edited by tha Guardians; 06-26-2009, 01:08 AM.

                    Originally posted by sonic-fast-fingers
                    can someone clarrify what QFT means my friend told me its quit ****ing talking, but im not 100 percent sure

                    Originally posted by Synthlight
                    I need a car that drives itself completely automated and I want it for free and it needs infinite gas mileage.

                    Cheers,

                    Synthlight

                    Comment

                    • Izzy
                      Snek
                      FFR Simfile Author
                      • Jan 2003
                      • 9195

                      #11
                      Re: Need help with Javascript

                      www.bluexoon.com/Izzy/PigLatin.exe

                      Figured it out.

                      Code:
                      using System;
                      using System.Collections.Generic;
                      using System.ComponentModel;
                      using System.Data;
                      using System.Drawing;
                      using System.Linq;
                      using System.Text;
                      using System.Windows.Forms;
                      
                      namespace WindowsFormsApplication1
                      {
                          public partial class Form1 : Form
                          {
                              public Form1()
                              {
                                  InitializeComponent();
                              }
                      
                              private void submit_Click(object sender, EventArgs e)
                              {
                                  string temp = "";
                                  string word = textBox.Text;
                      
                                  char[] delim = { ' ' };
                                  string[] stuff = word.Split(delim);
                      
                                  for (int i = 0; i < stuff.Length; i++)
                                  {
                                      temp = stuff[i];
                                      string letter = temp.Substring(0, 1);
                                      string part = temp.Substring(1, temp.Length - 1);
                                      stuff[i] = part + letter + "ay";
                      
                      
                                  }
                      
                                  textBox.Text = "";
                      
                                  for (int k = 0; k < stuff.Length; k++)
                                  {
                      
                                      textBox.Text = textBox.Text + stuff[k];
                                      if (k < stuff.Length - 1)
                                      {
                                          textBox.Text = textBox.Text + " ";
                                      }
                                      textBox.Refresh();
                                  }
                      
                                  
                      
                              }
                          }
                      }
                      Apparently I accidentally used a greater than symbol instead of a less than. Had to fix one more thing after that since it didn't like have a space at the end of the word after it printed it out for the second run.

                      Comment

                      • tha Guardians
                        MCDC 2011
                        • Nov 2006
                        • 1680

                        #12
                        Re: Need help with Javascript

                        Haha, this is great.
                        Not Javascript, but I'm having fun with it

                        Sending 15k
                        Tytyty

                        Originally posted by sonic-fast-fingers
                        can someone clarrify what QFT means my friend told me its quit ****ing talking, but im not 100 percent sure

                        Originally posted by Synthlight
                        I need a car that drives itself completely automated and I want it for free and it needs infinite gas mileage.

                        Cheers,

                        Synthlight

                        Comment

                        • Izzy
                          Snek
                          FFR Simfile Author
                          • Jan 2003
                          • 9195

                          #13
                          Re: Need help with Javascript

                          Thanks, I didn't really take 15k credits worth of time though.

                          Comment

                          • tha Guardians
                            MCDC 2011
                            • Nov 2006
                            • 1680

                            #14
                            Re: Need help with Javascript

                            I have over 600,000.
                            Doesn't matter.

                            Send some back if you'd like :P

                            Originally posted by sonic-fast-fingers
                            can someone clarrify what QFT means my friend told me its quit ****ing talking, but im not 100 percent sure

                            Originally posted by Synthlight
                            I need a car that drives itself completely automated and I want it for free and it needs infinite gas mileage.

                            Cheers,

                            Synthlight

                            Comment

                            Working...