DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   JavaScript / DHTML / AJAX (http://www.daniweb.com/forums/forum117.html)
-   -   populating text field in firefox not working (http://www.daniweb.com/forums/thread145321.html)

mjag16 Sep 11th, 2008 7:01 pm
populating text field in firefox not working
 
i have a simple url -
 <a href="javascript:displayWindow('Slice 2100 (Commercial)');">SLICE 2100 (Commercial)</a>

that passes the the variable in a javascript function -
                                <script language="javascript">
                    function displayWindow(url)
                    {
                        var w, h, l, t;
                                var nc;
                               
                        w = 600;
                        h = 409;
                        l = screen.width/4;
                        t = screen.height/4;
                               
                                nc = url;
                                document.forms['SellSheet'].elements['sellitsheet'].value = nc;                               
             
                // no title                       
                        // displayFloatingDiv('windowcontent', '', w, h, l, t);

                // with title                       
                        displayFloatingDiv('windowcontent', 'Floating and Dimming Div', w, h, l, t);                               
                       
                    }
                </script>

the function then prints our the variable in a text field but it doesn't show in firefox -

my text field
 <input type="text" style="width: 292px" class="myTextBox" id="sellitsheet" />

any ideas?

thanks

essential Sep 11th, 2008 9:47 pm
Re: populating text field in firefox not working
 
Hope this would help you!

Instead of this one -->
document.forms ['SellSheet'].elements['sellitsheet'].value = nc;

Try doing it like this -->
document.SellSheet.sellitsheet.value = nc;

mjag16 Sep 12th, 2008 8:21 am
Re: populating text field in firefox not working
 
thanks for the quick reply - but that doesn't work either. in fact, i originally had that string and changed it b/c i saw some post on the net saying firefox couldn't understand that type of syntax.

any other ideas?

thanks!

essential Sep 12th, 2008 11:17 am
Re: populating text field in firefox not working
 
This should work!
If not then try this reference guide @
http://developer.mozilla.org/en/The_DOM_and_JavaScript --

document.getElementsByTagName('form')['SellSheet'].elements['sellitsheet'].value = nc;

mjag16 Sep 15th, 2008 12:41 pm
Re: populating text field in firefox not working
 
still nothing - it's weird b/c i'll put a document.write in the function and it reads the passed variable but nothing i do gets the text field to populate in firefox or safari.

mjag16 Sep 15th, 2008 12:51 pm
Re: populating text field in firefox not working
 
never mind - got it to work - i had to put the
 document.getElementsByTagName('form')['SellSheet'].elements['sellitsheet'].value = url;
lind AFTER the call to my display function!

essential Sep 15th, 2008 9:28 pm
Re: populating text field in firefox not working
 
This should do it!
If you still need anythin', just let me know. Good day...

<html>
<head>
<title><!--Sample--></title>
<style type="text/css">
<!--
a { text-decoration: none; }
form input { border: none; }
#screen
{ position: fixed;
  left: 10px;
  top: 10px;
  text-align: center;
  font-weight: bold;
 
/* You may change the width and height if it is necessary.
*/
  width: 200px;
  height: 40px;
  background-color: #C0C0C0;
  color: #A6A6A6;
}
-->
</style>

<script type="text/javascript">
<!--
function load()
{ thisLink = document.getElementById('link1');
  thisLink.addEventListener('click', function displayWindow() {
  container = document.sellSheet.sellitsheet;  screen = document.getElementsByTagName('div')[0];
  screen.id = 'screen'; screen.firstChild.nodeValue = thisLink.title;
container.value = thisLink.title;
}, false );
}
//-->
</script>
</head>
<body onload="load();">
<p align="center">
<div>&nbsp;</div><br /><br />
<a id="link1" href="#" alt="" title="SLICE 2100 (Commercial)">SLICE 2100 (Commercial)</a><br />
<form name="sellSheet" action="#" onsubmit="return false;">
<input type="text" name="sellitsheet" size="20" value="" />
</form>
</p>

</body>
</html>


All times are GMT -4. The time now is 6:50 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC