473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Java script - forms..please help ASAP!

hi!

i'm new to java script. i'm doing a web page, where i can increment the value of a text field by pressing a button. Each time i press the button, the value in the text field should be incremented

i wrote a code for this and it returned an error

Line: 9
Char: 2
Error: Object Expected
Code: 0

The code is given below. Please tell me if there's an error in the code, or if you have a different solution - please let me know. i'm open to all ideas. would be nice if i got a solution as early as possible. thank you so much!


[HTML]<HTML>
<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -

function encode(text)
{
var temp= parseint(text);
temp +=1;
text = temp.toString();
document.form1.result.value = text;
}
// - End of JavaScript - -->
</SCRIPT>

</HEAD>
<BODY bgcolor="beige">


<FORM name="form1">
<table border=0><tr><br><td>
<INPUT TYPE=Button VALUE="submit" onClick="encode(this.form.input.value)"><tr><td>
Result:<td><INPUT NAME="result" TYPE=Text>

</table>
</FORM>
</BODY>
</HTML>[/HTML]
Oct 10 '07 #1
3 1449
gits
5,390 Expert Mod 4TB
hi ...

welcome to TSDN ...

have a look at the following (fixed) code:

[HTML]<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function encode(text) {
var temp= parseInt(text);
temp +=1;
text = temp.toString();
document.form1.result.value = text;
}
</SCRIPT>
</HEAD>
<BODY bgcolor="beige">
<FORM name="form1">
<table border=0>
<tr>
<td><INPUT TYPE=Button VALUE="submit" onClick="encode(this.form.result.value)">
Result:
<INPUT NAME="result" TYPE=Text value="0">
</td>
</tr>
</table>
</FORM>
</BODY>
</HTML>
[/HTML]
kind regards

ps: that is a hotfix :) ... following things were wrong: parseInt - js is case-sensitive, in your onclick-function you refered this.form.input.value - but input should be result, tabletags were completly messed up ... , value for the input type text should be 0 per default or you have to handle NaN in your function ...

hints: the language attribute for the script tag is deprecated use type="text/javascript" instead ..., write tag- and attribute-names in lower case, put quotes around attribute values ...
Oct 10 '07 #2
Thanks a bunch gits!!!!!!!!!!!

its working perfectly!

thank you again!!!

warm regards
Oct 11 '07 #3
gits
5,390 Expert Mod 4TB
hi ...

glad to hear that ;) ... post back to the forum anytime you have more questions ...

kind regards
Oct 11 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
1
by: Chris | last post by:
Our company developed the last couple of years a development tool: using this tool we configure and program (using SQL, and Java-Script) very, very easy an application. The output of the effort is...
6
by: Daniel Walzenbach | last post by:
Hi, I have an application using "Forms authentication". Everything works perfectly well except when I try to open a new page with java script like the following: <script...
7
by: dbabin | last post by:
I have a java script function enableServerList() {document.getElementById("ddlServers").disabled=false } function disableServerList() {document.getElementById("ddlServers").disabled=true } ...
36
by: Robert Baer | last post by:
I used Google and found some references for integer in Java. But "int" not only does not work, it also prevents reading X and Y coordinates of the mouse. What i would like to do: 1) Get X and Y...
7
by: GS | last post by:
we are using the following script for cursor to goto default position, is this script is java script or not?. can somebody tell me. I got this script from Internet, our client told us not to use...
24
jeffbroodwar
by: jeffbroodwar | last post by:
Hi everyone, Please help me accomplish the following : 1. how can i copy a file in java then paste it in a desired location 2. how can i run a .jar file run by just double clicking...
2
by: emily224 | last post by:
Hello, I have been trying to understand this source code, which I retreived from my online course test. I would like to know how to find the answer for the question on the test. Im sure the answer...
5
by: usha535140 | last post by:
Hi, In the intial page I want to dispay a check box ie for the first time I should display the page with check box ,If the check box is checked i need to dispaly the tabcontainer with the tabs.If it...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.