Jump to content

[SOLVED] Javascript script failing


straygrey

Recommended Posts

I have written a Javascript script as follows:-

function ClearForm()

 

    {

 

    document.getElementById("CardNumber").innerHTML = "";

 

    document.getElementById("MemberName").innerHTML = "";

 

    document.getElementById("Amount").innerHTML = " ";

 

    document.getElementById("Reason").innerHTML = " ";

 

    document.getElementById("Issue").disabled=true;

 

    document.getElementById("CardNumber").focus();

 

    }

 

and am confused as to why CardNumber and MemberName get cleared but Amount and Reason do not.

All fields are defined in HTML as :-

<input type=text with a name as well as an id.

They are all defined within their individual <div>

Link to comment
Share on other sites

change this

function ClearForm()

    {

    document.getElementById("CardNumber").innerHTML = "";

    document.getElementById("MemberName").innerHTML = "";

    document.getElementById("Amount").innerHTML = " ";

    document.getElementById("Reason").innerHTML = " ";

    document.getElementById("Issue").disabled=true;

    document.getElementById("CardNumber").focus();

    }

 

for this

 

function ClearForm()

    {
     document.myForm.reset();
    }

 

changing myForm to the name of the form you are using

Link to comment
Share on other sites

I have tried that as well and still it fails.

function ClearForm()

 

    {

document.Adjustments.reset();

    }

 

and I have

<title> Adjustments </title>

as well as

<form name="Adjustments" ID="Adjustments" method="get" action="InsertAdjustment.php">

in the HTML page.

Link to comment
Share on other sites

try this then

function ClearForm()

    {

    document.getElementById("CardNumber").value = "";

    document.getElementById("MemberName").value = "";

    document.getElementById("Amount").value= "";

    document.getElementById("Reason").value= "";

    document.getElementById("Issue").disabled=true;

    document.getElementById("CardNumber").focus();

    }

Link to comment
Share on other sites

Despite making these changes Amount & Reason still do not clear.

In the web page they are defined as :-

    echo '<div style="position:relative;"><input type=text name="Amount" id="Amount" onBlur="CheckAmount()"></div>';

 

    echo '<div style="position:relative;"><input type=text name="Reason" id="Reason" onBlur="CheckReason()"></div>';

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.