Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Javascript - The worst language know to mankind

  • 15-02-2005 11:10AM
    #1
    Closed Accounts Posts: 25


    Would anyone be able to help on this:

    The following code works OK in IE6.0 but does not work in Netscape 7.1

    <head>
    </head>
    <body onload="" ><div align="center"><div style="height:*; width:780px;" class="BkWhite">
    DMPR - H<BR>
    <form name="abcdForm" method="post" action="">

    <script>
    function updateResult(formname,destOut,destReturn,destReturnHidden){

    //alert("document.forms[formname].name: "+document.forms[formname].name);
    eval("var outText = "+document.forms[formname].name +"."+destOut+".options["+document.forms[formname].name +"."+destOut+".selectedIndex].text;");
    eval("var outValue = "+document.forms[formname].name+"."+destOut+".options["+document.forms[formname].name+"."+destOut+".selectedIndex].value;");

    eval(document.forms[formname].name+"."+destReturn+".value = outText;");
    if(destReturnHidden.length > 0){
    eval(document.forms[formname].name+"."+destReturnHidden+".value = outValue;");
    }
    }
    </script>

    <table width="100%">
    <tr>
    <td valign="top">
    <select name="abcdSelect" size="4"
    onchange="javascript:updateResult('abcdForm','abcdSelect','txtResult','')" style="width:140">
    <option value="A" selected="selected">AAA</option>
    <option value="B">BBB</option>
    <option value="C">CCC</option>
    <option value="D">DDD</option>
    </select>
    </tr>
    </table>
    <br/>
    <table width="100%">
    <tr>
    <td valign="top">
    Result: <input type="text" name="txtResult" value="AAA" readonly="readonly" style="width:140;border:0;color:black" />
    </td>
    </tr>
    </table>
    <br/>

    </html>
    </form>
    </td><!-- end main area -->
    </tr></table>
    </div>
    </div></div></body>
    </html>


Comments

  • Registered Users, Registered Users 2 Posts: 21,278 ✭✭✭✭Eoin


    Your HTML is all over the shop to be honest, try the following (you never said what exactly you wanted the page to do, so had to guess):

    edit: this works in Mozilla, so should work in Netscape
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    	<head>
    		<title>my page</title>
    		<script type="text/JavaScript">
    			function doValue()
    			{
    				document.myFrm.txt_Entry.value = document.myFrm.lst_Drop.value;
    			}
    		</script>
    	</head>
    	<body>
    		<form name="myFrm" action="thispage.html" method="post">
    			<table>
    				<tr>
    					<td>
    						<select name="lst_Drop" size="3" onChange="doValue()">
    							<option value="AAA">AAA</option>
    							<option value="BBB">BBB</option>
    							<option value="CCC">CCC</option>
    						</select>
    					</td>
    				</tr>
    				<tr>
    					<td>
    						<input type="text" name="txt_Entry" value="AAA" readonly>
    					</td>
    				</tr>
    			</table>
    		</form>
    	</body>
    </html>
    


Advertisement