/    Sign up×
Community /Pin to ProfileBookmark

how can i do it ?

i have a text field which has a default value . as soon as you click on it its value would be changed . i want to capture that changed value. i wrote a code but its not working. whats wrong ?

[code]
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”>
<HTML>
<head>
<script language=”JavaScript” type=”text/javascript”>
function setval(){ document.forms[0].field1.value=”15″ }

function catchvalue()
{

alert(“your value after calling setvalue() is”+document.forms[0].field1.value);

}

</script>

</head>
<form>
<input size=12 name=filed1 value=14 onclick=”setval()”; onchange=”catchvalue()” >

</form>

</HTML>

[/code]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@cofactorauthorNov 10.2004 — is it possible at all?
Copy linkTweet thisAlerts:
@7studNov 10.2004 — Not likely with this mistake:
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
&lt;HTML&gt;
&lt;head&gt;
&lt;script language="JavaScript" type="text/javascript"&gt;
function setval(){ document.forms[0].[color="red"]field1[/color].value="15" }

function catchvalue()
{

alert("your value after calling setvalue() is"+document.forms[0].field1.value);

}

&lt;/script&gt;

&lt;/head&gt;
&lt;form&gt;
&lt;input size=12 name=[color="red"]filed1[/color] value=14 onclick="setval()"; onchange="catchvalue()" &gt;

&lt;/form&gt;

&lt;/HTML&gt;


Try this:

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;

&lt;title&gt;js code&lt;/title&gt;
&lt;script language="JavaScript" type="text/javascript"&gt;

function setval(){ document.forms[0].field1.value="15" }

function catchvalue()
{

<i> </i>alert("your value after calling setvalue() is"+document.forms[0].field1.value);

}

&lt;/script&gt;

&lt;/head&gt;
&lt;form&gt;
&lt;input size=12 name=field1 value=14 onclick="setval(); catchvalue()" &gt;

&lt;/form&gt;

&lt;/html&gt;
×

Success!

Help @cofactor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...