06-26-2009, 01:01 AM | #1 | ||
MCDC 2011
|
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?
__________________
Quote:
Quote:
|
||
06-26-2009, 01:08 AM | #2 |
Snek
Join Date: Jan 2003
Location: Kansas
Age: 34
Posts: 9,192
|
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.
|
06-26-2009, 01:15 AM | #3 | ||
MCDC 2011
|
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.
__________________
Quote:
Quote:
|
||
06-26-2009, 01:19 AM | #4 |
Snek
Join Date: Jan 2003
Location: Kansas
Age: 34
Posts: 9,192
|
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. |
06-26-2009, 01:24 AM | #5 | ||
MCDC 2011
|
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.
__________________
Quote:
Quote:
|
||
06-26-2009, 01:26 AM | #6 |
Snek
Join Date: Jan 2003
Location: Kansas
Age: 34
Posts: 9,192
|
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.
|
06-26-2009, 01:31 AM | #7 | ||
MCDC 2011
|
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?
__________________
Quote:
Quote:
|
||
06-26-2009, 01:55 AM | #8 |
let it snow~
|
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. |
06-26-2009, 01:57 AM | #9 |
Snek
Join Date: Jan 2003
Location: Kansas
Age: 34
Posts: 9,192
|
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) { } } } Last edited by Izzy; 06-26-2009 at 02:00 AM.. |
06-26-2009, 02:02 AM | #10 | ||
MCDC 2011
|
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.
__________________
Quote:
Quote:
Last edited by tha Guardians; 06-26-2009 at 02:08 AM.. |
||
06-26-2009, 10:16 PM | #11 |
Snek
Join Date: Jan 2003
Location: Kansas
Age: 34
Posts: 9,192
|
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(); } } } } |
06-26-2009, 11:18 PM | #12 | ||
MCDC 2011
|
Re: Need help with Javascript
Haha, this is great.
Not Javascript, but I'm having fun with it Sending 15k Tytyty
__________________
Quote:
Quote:
|
||
06-27-2009, 01:35 AM | #13 |
Snek
Join Date: Jan 2003
Location: Kansas
Age: 34
Posts: 9,192
|
Re: Need help with Javascript
Thanks, I didn't really take 15k credits worth of time though.
|
06-27-2009, 07:32 PM | #14 | ||
MCDC 2011
|
Re: Need help with Javascript
I have over 600,000.
Doesn't matter. Send some back if you'd like :P
__________________
Quote:
Quote:
|
||
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|