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
https://forums.phpfreaks.com/topic/48271-solved-javascript-script-failing/
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

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.

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();

    }

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>';

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.