/    Sign up×
Community /Pin to ProfileBookmark

RE: Using image instead of form "reset" button / functionality problem

Hi, there friends…

in my JS tackling I bounced to this problem which I cannot come to a successful end with:

I have a form with input text fields, at the bottom of the form there was originally reset button:
<input type=”reset” name=”reset” value=”Clear”

onClick=”D_button()” class=”button”>

I have made a nice piece of .gif graphic button and intend to
replace this greyish form button. So I did this:

<a onClick=”javascript?_button()”>
<img style=”cursor:hand” src=”/extras/images/hypo_clear_btn.gif” border=”0″ width=”66″ height=”21″ alt=”Clear values”></a>

THIS DOES NOT CLEAR THE INPUT TEXT FIELDS!!! I have tried
several changes but no positive result. 🙁

The JS function called looks like this:
function D_button()
{
document.hypo.button.disabled=true;
}

PLEASE, give me a hint. Thank u very much

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@PittimannMar 04.2004 — Hi!

Just try something like:

<a href="#" onClick="D_button();return false;">

<img src="/extras/images/hypo_clear_btn.gif" border="0" width="66" height="21" alt="Clear values"></a>

and in your function:

function D_button()

{

document.hypo.button.disabled=true;

document.forms[0].reset();

}

Cheers - Pit
Copy linkTweet thisAlerts:
@nemo7111authorMar 04.2004 — Thanks a lot. This way it works !

Aachen is a lovely city. :-)
Copy linkTweet thisAlerts:
@PittimannMar 04.2004 — Hi!

You're welcome!!Aachen is a lovely city. :-)[/QUOTE]Yes - that's why I live here - and I do so voluntarily :p

Cheers - Pit
Copy linkTweet thisAlerts:
@nemo7111authorMar 04.2004 — Hi,

The trick u sent me is absolutely ok, BUT there is another button called "CALCULATE" and when I wanted to aplly image even to this one I mean I did this:

formerly it was:

<input type="button" value="Calculate" onClick="calc(this.form)" name="button" disabled="true"; class="button">

I changed to:

<a href="#" onClick="calc(this.form);">

<img src="/extras/images/hypo_calc_btn.gif" border="0" width="66" height="21" alt="Calculate monthly payment"></a>


The status after I adde image to this button is that this one works ( it calculates the result) but the other one "CLEAR" does not work.

I have a feeling there might be a problem with the function linked with this button:

function calc(form)

{

var repay_m =0;

document.hypo.result.value=(repay_m);

var i=(document.hypo.uvery.value)/1200;

var d= parseFloat(ignoreSpaces(document.hypo.d.value));

var f=(document.hypo.fixnasadzba.value);

var n=12*(parseFloat(document.hypo.n.value));

repay_m=d*
(i/(1-Math.pow(1/(1+i),n)));

repay_m= Math.ceil(repay_m);

if (f!="")

{

if (d=="" || isNaN(d) || isNaN(n))

{

//alert("Zadajte správnu výšku úveru.");

document.hypo.d.focus();

document.hypo.d.select();

}

else

{

document.hypo.result.value=(repay_m);

}

}

}

function D_button()

{

document.hypo.button.disabled=true;

document.forms[0].reset();

}

function check()

{

var n=document.hypo.n.value;

var f=(document.hypo.fixnasadzba.value);

var d= parseFloat(ignoreSpaces(document.hypo.d.value));

if (f!="")

{

if (d=="" || isNaN(d))

{

//alert("Zadajte správnu výšku úveru.");

document.hypo.button.disabled=true;

}

else

{

if (n!=0)

{

document.hypo.button.disabled=false;

}

else

{

document.hypo.button.disabled=true;

}

}

}

}

I do not want to eat up your time. This is the last one I promise :-)
Copy linkTweet thisAlerts:
@PittimannMar 04.2004 — Hi!

Now, after doing that, the button no longer exists.

So the "mistake" is in the function:

function D_button() {

[COLOR=red]document.hypo.button.disabled=true;[/COLOR]

document.forms[0].reset();

}

Simply remove the red line and it will work. By the way, I didn't know the name of your form. The "forms[0]" refers to the first form in your document. If you add another form(s) above this one, it won't work. So you better replace this with "hypo" like in the other functions...

Cheers - Pit

Edit: I forgot to mention, that the whole stuff referring to the former button has to be removed (in the check function). If you want some effect like you had before (enable - disable) you could use an input type=image instead of the anchor with an image or do some image swapping.
Copy linkTweet thisAlerts:
@nemo7111authorMar 04.2004 — Ok. Thanks a million. :-) Works like swiss watch. Have a nice time.
Copy linkTweet thisAlerts:
@PittimannMar 04.2004 — Hi!

You're welcome again! Have a nice time too...

Cheers - Pit
Copy linkTweet thisAlerts:
@meanboyNov 26.2004 — hi,

i have a similar problem too. i have a image i want to put as a button. my exising button has this function

<input onClick="calBMI(this.form, this.form.meters.value, this.form.kilograms.value)" type=button value=Calculate name=calc>

how am i able to integrate this function to e image button. pls help.. thanks..
×

Success!

Help @nemo7111 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.16,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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