Page to test a text manipulation function

F

Fabian

I have created a javascript to manipulate a text strong given to it. It
works in all the situations I put it in. Now, I want to create a form
based interface. Essentially, the use types in the text in a form text
box, and it returns the manipulated text.

Ideally, I'd like it to return teh text in teh same page, without
reloading anything from the server. Problem is, I have no idea how to
capture anything entered into a form with javascript.

Help?
 
F

Fabian

Fabian hu kiteb:
I have created a javascript to manipulate a text strong given to it.
It works in all the situations I put it in. Now, I want to create a
form based interface. Essentially, the use types in the text in a
form text box, and it returns the manipulated text.

Ideally, I'd like it to return teh text in teh same page, without
reloading anything from the server. Problem is, I have no idea how to
capture anything entered into a form with javascript.

ok, Ive found a script online which does mostly what i want. The problem
now, is weird.

---snip---

<SCRIPT LANGUAGE="JavaScript" SRC="numri.js">
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="numri-jp.js">
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">
<!--
function response() {
var newtitle = document.form1.NumberInput.value;
var head1 = document.getElementById("head1");
en_uk.firstChild.nodeValue = numri(newtitle);
jp_ka.firstChild.nodeValue = numri-jp(newtitle);
}

function Xejn() { }
// -->
</SCRIPT>

<form name="form1">
<input type="text" name="NumberInput" size="25">
<input type="button" value="Change!" onClick="response();">
</form>

<HR>

<P>British English:<SPAN ID="en_uk"> </SPAN></P>
<P>Japanese:<SPAN ID="jp_ka"> </SPAN></P>
---snip---

The first two scripts loaded are rather convoluted text manipulation
scripts, for English and Japanese, respectively. The problem is that the
page utterly fails to find the numri-jp function. I can't see why not.
If I add the following line (and delete the numri-jp.js reference), it
won't work.

<SCRIPT LANGUAGE="JavaScript">
function numri-jp(i) {
return i;
}
</SCRIPT>

BUT if I then change all refernces to numri-jp() to numrijp(), it will
find the function. What's up with that?
 
F

Fabian

Problem solved. I was using = instead of == in some if statements.

Thanks for your help, everyone who replied to this thread. You were
great. Couldn't have done it without you guys.
 
D

Dr John Stockton

JRS: In article <[email protected]>, seen in
news:comp.lang.javascript said:
I have created a javascript to manipulate a text strong given to it. It
works in all the situations I put it in. Now, I want to create a form
based interface. Essentially, the use types in the text in a form text
box, and it returns the manipulated text.

Ideally, I'd like it to return teh text in teh same page, without
reloading anything from the server. Problem is, I have no idea how to
capture anything entered into a form with javascript.


<URL:http://www.merlyn.demon.co.uk/js-quick.htm> does not do that; but
it uses techniques required to do that, and is reasonably short. View
Source. Make F.Result a textbox like F.Code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top