It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

javascript help

javascript help

Postby Garcilazo on Mon Mar 10, 2008 7:29 pm

how we use a variable within and object name?
for example if i want to get the value of an input box:
var x = document.theform.variable.value
where variable is an input field in the form

:? thanks for the help :P
Garcilazo
 
Posts: 5
Joined: Thu Mar 06, 2008 8:40 pm

Postby rangana on Tue Mar 11, 2008 1:14 am

The easiest way is to name your input field.For example, you have this in your page:
Code: Select all
<form name="myform" action="#" method="post">
<input type="text" name="myinput">
<input type="button" onclick="show()" value="Show Input Value">
</form>


If you want to get the value of the input box, it is as easy as:
Code: Select all
function show()
{
var accept = document.myform.myinput.value
alert ('Did you key in '+accept +' right?');
}


Hope made sense ;)
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby Garcilazo on Tue Mar 11, 2008 1:18 am

we have that we are making a chess game and we have letters for the pieces and we need to figure out how to move them from one input to another input

rangana wrote:The easiest way is to name your input field.For example, you have this in your page:
Code: Select all
<form name="myform" action="#" method="post">
<input type="text" name="myinput">
<input type="button" onclick="show()" value="Show Input Value">
</form>


If you want to get the value of the input box, it is as easy as:
Code: Select all
function show()
{
var accept = document.myform.myinput.value
alert ('Did you key in '+accept +' right?');
}


Hope made sense ;)
Garcilazo
 
Posts: 5
Joined: Thu Mar 06, 2008 8:40 pm

Postby rangana on Tue Mar 11, 2008 1:28 am

User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Postby Garcilazo on Tue Mar 11, 2008 1:32 am

thanks that should help

rangana wrote:No, not that easy to explain. Maybe this link would help:
http://javascript.internet.com/games/ja ... -oppo.html
http://javascript.internet.com/games/ch ... -v1.0.html ;)
Garcilazo
 
Posts: 5
Joined: Thu Mar 06, 2008 8:40 pm


Who is online

Users browsing this forum: No registered users and 6 guests