Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This.Form not working. 2

Status
Not open for further replies.

mbiro

Programmer
Nov 20, 2001
304
Can anyone tell me why the first form works, but the send doesn't?

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript"><!--
function link(x,what) {
what.mySelect.value = what.mySelect.value.toUpperCase();
}
//--></SCRIPT>
</HEAD>
<BODY>
<FORM>
<INPUT TYPE="text" NAME="mySelect">

<INPUT TYPE="BUTTON" NAME="upper" onClick="link(2,this.form)">
</FORM>

<FORM>

<INPUT TYPE="text" NAME="mySelect">

<a href="javascript:link(2,this.form)" onClick="link(2,this.form)">Upper</a>
</form>

</BODY>
</HTML>
 
the anchor tag is not a member of the form.

do this instead:

Code:
function link(theFormName) {
            var theSel = document.forms[theFormName].elements['mySelect'];
            theSel.value = theSel.value.toUpperCase();
        }

Code:
    <BODY>
        <FORM name="f1">
        <INPUT TYPE="text" NAME="mySelect">

        <INPUT TYPE="BUTTON" NAME="upper" onClick="link('f1');">
        </FORM>

        <FORM name="f2">

        <INPUT TYPE="text" NAME="mySelect">

        <a href="#" onClick="link('f2'); return false;">Upper</a>
        </form>

    </BODY>

*cLFlaVA
----------------------------
[tt]your mom goes to college[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
>[tt]<a href="javascript:link(2,this.form)" onClick="link(2,this.form)">Upper</a>[/tt]
The closest to perform is this.
[tt]<a href="javascript:void(0)" onClick="link(2,this.parentNode)">Upper</a>[/tt]
 
Both of these worked great. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top