PDA

View Full Version : Help with verifying and, well a script..


vkidv
10-09-2002, 10:17 PM
i play this game called neopets and im making a site about it.

theres a function in the game where you message other people in the game, using a form...i want to be able to access this form from my website, however with a few changes.

here is a snippet from the site's form:
<quote>
<form name='neomessage' action='process_neomessages.phtml' method='post'>
<table align=center cellpadding=4 cellspacing=0 border=0 width=540>

<tr><td width=220 bgcolor=#dddd77>
<b>To : </b><br><font size=1>(type their username, or select from your NeoFriends)</font><br>
</td><td width=320 bgcolor=#ffffee>
<input type='text' name='recipient' value='' size=12 maxlength=20>
<select name='neofriends' onChange='update_buddy()'>
<option selected>Please Select<option value='8000jman0007'>8000jman0007<option value='9000jman0009'>9000jman0009<option value='coolwu007'>coolwu007<option value='davis00720'>davis00720<option value='el_brillioso'>el_brillioso<option value='ftgrg'>ftgrg<option value='funkychcik2002'>funkychcik2002<option value='improfane'>improfane<option value='joshynet'>joshynet<option value='keren'>keren<option value='key'>key<option value='kiba344'>kiba344<option value='lozzy_chic72'>lozzy_chic72<option value='luv2run90'>luv2run90<option value='lynzo601'>lynzo601<option value='shootist_prime'>shootist_prime<option value='vhogv'>vhogv<option value='vsykov'>vsykov</select>
</td></tr>

<tr><td bgcolor=#dddd77>
<b>Subject : </b><br>
<font size=1>(choose a preset or use your own)</font><br>
</td><td bgcolor=#ffffee>
<input type='text' name='subject' size=18 maxlength=30>
<select name='message_type' onChange='update_title()'>
<option selected>Select a preset title!
<option>Random Chat
<option>Pet Related
<option>Declaration of War!
<option>Can you help me?
<option>I noticed you around...
<option>Want to Trade?
<option>I'm bored. Talk to me, please.
<option>My pet is after your blood!!!
</select>
</td></tr>

<tr><td bgcolor=#dddd77 valign=top>
<b>Message :</b><br>
</td><td bgcolor=#ffffee>
<textarea name='message_body' rows=6 cols=50>Please type your message in here</textarea><p><center><input type='button' value='Send a Neomail™' OnClick="checkusername();" ></center>
</td></tr>

</table>
</form>
</quote>
then i want to be able to replace the message_body with a hidden input type. and make it so on my site you can change the body's text infomation...here is a script i have come up with
<html>
<script>
item=document.me2.item2.value
trick1=""+rec+" has giving you "+item+"."
trick2=""+rec+" has giving you "+item+"."
function dothat()
{
rec=document.me.recipient.value
if ((rec==null) || (rec==""))
{
alert("please type in a username to send this neomail to!");
document.me.recipient.focus();
}
else
rec2=document.me.message_body.value
rec3="You have been foooled by "+rec+"!"
}

function dothat2()
{
if ((item==null) || (item==""))
{
document.me.recipient.value="Dark Faerie Doll"
}
}
</script>
<form name="me">
<input type='text' name='recipient' value='' size=12 maxlength=20>
<input type='hidden' name='message_body' value=''>
</form>
<form name="me2">
<input type='text' name='item2' value='' size=12 maxlength=20>
</form>
<a href="javascript:alert(trick1);">click</a>
</html>


sum this up:
i want to be able to use javascript to i dynamically (i think dynamically) to change the value of message body on what button the visitor choose (by a link or radio button)

please help me if you undertsand

ShriekForth
10-10-2002, 04:57 PM
To acces the message_body is quite simple. Like this... trick1 can be whatever messge you wated to generate.


<a href="javascript:setBody(trick1)">click</a>

<script>
function setBody(msg){
document.neomessage.message_body.value = msg;
}
</script>


In the case of what you have posted here it will be " has given you ". the reference to rec I am guessing should be the recipient, document.neomessage.recipient.value. And item is blank. but the above but is the reference you need to change the message_body. That will overwrite all in the body. If you want to just append, then

document.neomessage.message_body.value += msg;

will work.

ShriekForth