Click to See Complete Forum and Search --> : entering values in a form without refreshing


OutSider
08-06-2003, 09:38 AM
i'm trying to make something for a text-based webgame, since you have to fight, you have values like defences, strenght & so on

to make it easyer for the users, instead of just typing a value in each field, i tried to make something with javascript that they should just copy paste the entire line in the textarea and by pressing on of the 2 buttons on the bottom, certain values are entered in one of the 2 rows above (depending on wich button)

this is what it should be (http://users.pandora.be/itdon/FA/durandal/temp.html)

when someone enters the following in the textarea
Swamp Rat (sacrifice) Rat/earth, dead L16 48/72 F50/D0/A50/E100
and then presses the first button for example,
then the script should place:
48 in row 1, box1
72 in row 1, box2
50 in row 1, box3
0 in row 1, box4
50 in row 1, box5
100 in row 1, box6

ive seem something like this on a webpage somewhere, but i wasnt allowed to use that script from the owner

if you need any more info, just ask

zachzach
09-03-2003, 04:12 PM
extremly impresseve
1.your even TRYing to make that, and since im a intermediate
i'm impressed
2.wow.double wow.you acually asked the guy.im not saying i steal scripts and call then my own, but ALOT of people do

anyway,

i know this is not javascript, but its still a script:
i have a javascript and vbscript combo soulution

ever heard of the vbscript function Split()?
and theres alot of cool stuff like Len() {lenth} and more

anyway, check out a vbscript website, or you can try to wing it
(unlikly it'll work)

i can help a little though:

have then type in this:

Swamp Rat (sacrifice) Rat/earth, *dead L16 &48/72 F50/D0/A50/E100
lets call that string0 (thats the name not just what were calling it)
then make a substing of * till &(youll find out later how)
and a substring of & to the end(youll find out later how)

lets call the first one string 1
and the second string2

1.)
first, to make string 1 dead and L16 seperate:
sting3 = Split(sting1, " ")
then you can call string3(0) and you get dead, and then you can call sring3(1) and you get L16

2.)
sencond, to make sting 2 seperated into all of those numbers so we can put them into boxes individually:
sting4 = Split(sting2, "/")
then you can call the first number(48) by using this code:
string4(0)
the second number by using this:
string4(1)
ect.
(and yes the number 0 is the first thing, so dont think:
string4(1) will call the first, it calls the second one,remember that its importent)

3.)
back to making sting 1 and 2
if you havn't figured out how, this is how:

stringA = Split(string0, "*")
sting1 = stringA(1)
stingB = Split(string0, "&")
string2 = stringB(1)

4.)
the tables:
you can pass a var (like string1) between a code block and another, even between javascript and vbscript
so just:

document.write("<table>")
document.write("<td>" + string4{note:or-whatever} + "</td>")
document.write("</table>")

now about the sacrifice and other stuff, i thing youll find some way im just kinda getting tiered of typing, and if anyone has sugestions or sees problems, dont tell me tell OutSider!
anyway, OutSider, if i find out anthing else, i'll tell you...somehow...

so i hope that helps:)
bye:)