| View previous topic :: View next topic |
| Author |
Message |
Garcilazo
Joined: 06 Mar 2008 Posts: 5
|
Posted: Mon Mar 10, 2008 8:29 pm Post subject: javascript help |
|
|
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  |
|
| Back to top |
|
 |
|
|
rangana 250+ Club

Joined: 27 Feb 2008 Posts: 439 Location: Cebu City Philippines
|
Posted: Tue Mar 11, 2008 2:14 am Post subject: Re: javascript help |
|
|
The easiest way is to name your input field.For example, you have this in your page:
| Code: |
<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: |
function show()
{
var accept = document.myform.myinput.value
alert ('Did you key in '+accept +' right?');
}
|
Hope made sense  |
|
| Back to top |
|
 |
Garcilazo
Joined: 06 Mar 2008 Posts: 5
|
Posted: Tue Mar 11, 2008 2:18 am Post subject: Re: javascript help |
|
|
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: |
<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: |
function show()
{
var accept = document.myform.myinput.value
alert ('Did you key in '+accept +' right?');
}
|
Hope made sense  |
|
|
| Back to top |
|
 |
rangana 250+ Club

Joined: 27 Feb 2008 Posts: 439 Location: Cebu City Philippines
|
|
| Back to top |
|
 |
Garcilazo
Joined: 06 Mar 2008 Posts: 5
|
Posted: Tue Mar 11, 2008 2:32 am Post subject: Re: javascript help |
|
|
thanks that should help
|
|
| Back to top |
|
 |
|