JavaScript - Add Row With Text Size
I have this javascript to add a row to html:
Code: <html> <body> <?php $vendor = $_POST['vendor']; $vendor_phone = $_POST['vendor_phone']; $vendor_email = $_POST['vendor_email']; ?> <table width=930> <tr> <td style="text-align: center" width=356><img src="http://www.shopphgmag.com/po/images/cwplogo.jpg"/><br> <p ><br> br> Ph: <br> Fax: </p></td> <td width=500></td> <td> <Fieldset> <legend>Purchase Order</legend> Number: </fieldset> </td> </tr> <td colspan="3"> <fieldset> <legend>Issued To</legend> <table> <tr> <td>Vendor: </td> <td><?php echo $vendor; ?></td> </tr> <tr> <td>Vendor Phone: </td> <td><?php echo $vendor_phone; ?></td> </tr> <tr> <td>Vendor Email: </td> <td><?php echo $vendor_email; ?></td> </tr> </table> </fieldset </td> </table> <script language="javascript"> function addRow() { var tbody = document.getElementById("po_table").getElementsByTagName("tbody")[0]; var row = document.createElement("TR"); var cell1 = document.createElement("TD"); var cell2 = document.createElement("TD"); var cell3 = document.createElement("TD"); var inp1 = document.createElement("INPUT"); inp1.setAttribute("type","text"); inp1.setAttribute("name","quantity[]"); cell1.appendChild(inp1); var inp2 = document.createElement("INPUT"); inp2.setAttribute("type","text"); inp2.setAttribute("name","description[]"); cell2.appendChild(inp2); var inp3 = document.createElement("INPUT"); inp3.setAttribute("type","text"); inp3.setAttribute("name","unit_cost[]"); cell3.appendChild(inp3); row.appendChild(cell1); row.appendChild(cell2); row.appendChild(cell3); tbody.appendChild(row); } function removeRow() { var table = document.getElementById("po_table").getElementsByTagName("tbody")[0]; var lastRow = table.rows.length; if (lastRow > 2) table.deleteRow(lastRow - 1); } </script> </head> <body> <form method="post" action="review_po.php"> <input type="button" value="Add Row" onClick="addRow();"> <input type="button" value="Delete Row" onclick="removeRow()"> <table id="po_table" border="1"> <tbody> <tr> <th bgcolor="#c1c1c1" width="30px">Quantity</th> <th bgcolor="#c1c1c1" width="340px">Description</th> <th bgcolor="#c1c1c1"width="30px">Unit Cost</th> </tr> <tr> <td><input type=text name="quantity[]"></td> <td><input type=text name="description[]" size="100"></td> <td><input type=text name="unit_cost[]"></td> </tr> </tbody> <tfoot> <tr> <th bgcolor="#e0e0e0">1</th> <th bgcolor="#e0e0e0">Shipping</th> <td><input type=text name="shipping"></td> </tr> <tr> <th bgcolor="#e0e0e0">1</th> <th bgcolor="#e0e0e0">Tax</th> <td><input type=text name="tax"></td> </tr> </tfoot> </table> </br> <table width=930> <tr width=930> <td><input type="submit" value="Back" name="/po/po/add_vendor.html" style="float:left"></td> <td><input type="submit" value="Review" name="review_po" style="float:right"></td> </tr> </table> </form> </body> </html> It works great, but I need the var inp2 textbox to be size=100 I can't figure out how to do it. Here is my page: http://shopphgmag.com/po/po/add_items.php and you can see if you click "add row" it adds the row with a smaller text box than the other row Similar TutorialsHi, I've written a function to change the font, this is working in IE but not in FF or Chrome. No errors come up in Firebug. Once this is working in both browsers I will change the function to gradually increase the size of the font to make it look as if the font is growing. This is why I haven't just assigned a class to the text. URL of the site with the script is http://dev.creativepanda.co.uk/ Function in question is - Code: function alterFontSize(){ var sizeElem = document.getElementById('sizeTest').style; if(reverse == 0 && currentFontSize < endFontSize){ currentFontSize = endFontSize; sizeElem.fontSize = currentFontSize; } } Thanks for any help. Dear All, I have tried to change the text colour and size but with no successful. I have two files. (a) Test.html (b) marquee.js Any advise is highly appreciated. (a) Test.html code is stated as below : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> <html> <head><script type="text/javascript" src="marquee.js"></script> <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" > <title>Test</title> </head> <center> <body bgcolor="#fffff"><div id="fade_base" style="BORDER-RIGHT: 0px dotted; PADDING-RIGHT: 0px; BORDER-TOP: black 0px dotted; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: black 0px dotted; WIDTH: 250px; LINE-HEIGHT: 1.8em; PADDING-TOP: 5px; BORDER-BOTTOM: black 0px dotted; HEIGHT: 60px"> <br> <strong><em><a id="fade_link"></a></em></strong> </div> </center> </body> </html> (b) marquee.js file is stated as below function setupFadeLinks() { arrFadeLinks[0] = ""; arrFadeTitles[0] = "..Business Presentation..."; arrFadeLinks[1] = ""; arrFadeTitles[1] = "..Art of Public Speaking..."; arrFadeLinks[2] = ""; arrFadeTitles[2] = "...Business Meeting..."; arrFadeLinks[3] = ""; arrFadeTitles[3] = "..Increase Confidence..."; arrFadeLinks[4] = ""; arrFadeTitles[4] = "...Workshop..."; } // You can also play with these variables to control fade speed, fade color, and how fast the colors jump. var m_FadeOut = 255; var m_FadeIn=0; var m_Fade = 0; var m_FadeStep = 3; var m_FadeWait = 1600; var m_bFadeOut = true; var m_iFadeInterval; window.onload = Fadewl; var arrFadeLinks; var arrFadeTitles; var arrFadeCursor = 0; var arrFadeMax; function Fadewl() { m_iFadeInterval = setInterval(fade_ontimer, 10); arrFadeLinks = new Array(); arrFadeTitles = new Array(); setupFadeLinks(); arrFadeMax = arrFadeLinks.length-1; setFadeLink(); } function setFadeLink() { var ilink = document.getElementById("fade_link"); ilink.innerHTML = arrFadeTitles[arrFadeCursor]; } function fade_ontimer() { if (m_bFadeOut) { m_Fade+=m_FadeStep; if (m_Fade>m_FadeOut) { arrFadeCursor++; if (arrFadeCursor>arrFadeMax) arrFadeCursor=0; setFadeLink(); m_bFadeOut = false; } } else { m_Fade-=m_FadeStep; if (m_Fade<m_FadeIn) { clearInterval(m_iFadeInterval); setTimeout(Faderesume, m_FadeWait); m_bFadeOut=true; } } var ilink = document.getElementById("fade_link"); if ((m_Fade<m_FadeOut)&&(m_Fade>m_FadeIn)) ilink.style.color = "#" + ToHex(m_Fade); } function Faderesume() { m_iFadeInterval = setInterval(fade_ontimer, 10); } function ToHex(strValue) { try { var result= (parseInt(strValue).toString(16)); while (result.length !=2) result= ("0" +result); result = result + result + result; return result.toUpperCase(); } catch(e) { } } Best Regards Hexian i want to adjust text size according to a page without scrollers. e.g the page should be shown that its scrollers are off and the text on the page spread from top to bottom.
I have an iframe that is a specific height and width. I want to detect whenever the the iframe is no longer exactly the height i set it to. If a user has CSS turned off for example the iframe will be in default height and width. I want to detect that. This is how you'd normally do it but this only returns the original size (try with 'no style' in Firefox): Code: function getSize() { alert('height is now '+document.getElementById("Iframemain").height) alert('height is now '+document.getElementById("Iframemain").width) } Is it possible? As of right now I have a code that will work in IE but wont work in FireFox...go figure. Basically what I want to have happen is when you type in an area code it will provide an output in a predetermined area of the page. For Example: Input- 512 Output - Austin, TX The code that I have doesn't work with firefox and I was just wondering if there was a code that would allow that to happen. Thanks! Hi, I have a form with 9 text fields and a text area. What I want to do is replace the text in the text area depending on how many fields contain text. For example my text boxes are named 1 to 9, if the user enters text in the first five boxes I want the text area to auto fill with 'you have selected boxes 1 to 5' if the user selects all nine it will say 'you have selected 1 to 9', therefore, the user must complete the text boxes in order. I have it working with an onchange event but i have a button on the form to also auto fill the text boxes and it does not work if this is clicked. Any help would be appreciated! Hi all, Thanks for reading. I'm having an issue trying to accomplish the following - I have a text field (field1) already displayed on the HTML page. However, there's a link where you can add additional text fields to the page as well. When the link is clicked, the second text field is added successfully (field2), and when the link is clicked again, the third text field (field3) is added successfully. However, the third field does not add itself to the page, and the text for anything greater than a third field also isn't displayed after. This obviously means that my "fields" variable is not working right, so I'm wondering, would anyone be able to assist me to help me get that variable processing correctly? Code: <script language="javascript"> fields = 1; function addMore() { if (fields = 1) { document.getElementById('addedMore').innerHTML = "<input type='text' name='field2' size='25' /> <span>Field 2.</span>"; fields = 2; } else if (fields = 2) { document.getElementById('addedMore').innerHTML = "<input type='text' name='field3' size='25' /> <span>Field 3.</span>"; fields = 3; } else { document.getElementById('addedMore').innerHTML = "Only 3 fields are allowed."; document.form.add.disabled=true; } } </script> Here is the code in my HTML - Code: <input type="text" name="field1" size="25" /> <span>Field 1.</span> <div id="addedMore"></div> <p class="addMore"><form name="add"><a onclick="addMore()">Add another field.</a></form></p> Thank you very much. Hi, I want to know how we can get the cookie size. In Mozilla firefox i got Name Value Host Path Expire. The same way i want to get cookie size also . Please advise me how can i get it using javascript. I need to make a pop up window at a certain size containing just a form but i cant find anywhere the code to control window size. Can anyone post a quick example of it? Also it would be handly if the title bar was disabled too =P
Hello, How can we calculate size of image by using javascript ? Thanks in advance I am using this javascript code to detect screen size and display an alternate css. Code: if (screen.width<1600) { document.write('<link rel="stylesheet" href="<?php echo $path ?>/css/templateadjust.css" type="text/css" />'); } This works fine in FF and Chrome but doesn't seem to work in IE. Any idea why? Hello, First I want to say I have no experience with coding, I develop eLearning via Adobe Captivate. We recently implemented a new LMS from PeopleSoft. This new LMS is launching the eLearning in a small browser window probably 500x400 without the ability to resize this. I am wondering first, if it's possible to edit the htm/js file that Captivate produces, and if anyone is aware of code that could then be entered into the htm/js file to resize the browser upon launch? Thanks! I have dealt with window open before and i know how to adjust the size of the window in the parameters assigned but i have never dealt with window.opener before and have had several failed attempts and adjusting the window size here.. any help would be appreciated.. there is some inline css that i can change the background and stuff but i tried using height and width in the css to no avail, so i thought i would ask do i need to assign a new var inside the script ? how do i change the size. ? it needs to be 300x300 thanks Code: <script language="JavaScript"> var host = '<?php echo $_SERVER['HTTP_HOST'];?>'; var win = false; if (window.opener) { win=window.opener; } else if (top.document) { win=top.document; } if (!win || win.location.href.toString().indexOf('<?php echo $parent_href;?>')==-1) { window.location.href = '<?php echo $parent_href;?>'; } Hi there I know this picture_viewr js is a fullscreen slide Would it be possible to set a screen size (700x500 e.g.) and then set a background color or the part that would be outside this window??? Thx a lot allberto http://www.alfaaudiovisual.com/pictu...er/ByB/ByB.htm Hi, this will probably make a bit more sense it you read my topic in the HTML section (http://www.codingforums.com/showthread.php?t=57093) where I had a problem with two floating divs, in the end the solution was to give both on my floating divs a fixed width. Now, the menu bar div will always be 150 pixels and i wanted the remaing width to be taken up by the main content div. This script here seems to work very wel in firefox but in ie I get scrollbars. This seems to be because firefox returns the actuall width of the viewing 'frame' while IE seems to give the width of the window itself. PHP Code: <script type="text/javascript"> onload = function getBrowserWidth() { if (!document.all) { var width = document.body.offsetWidth; var newWidth = width - 150; document.getElementById('main').style.width = newWidth; } } </script> After a bit of playing with it I found that IE seems to return in offsetWidth about 19 more pixels than the actual size of the viewable 'frame', can anyone confirm this? Now, when the browser window is resized I want the width of the element to be resized as well, which meant I had to add to the body tag <body onresize="getBrowserWidth();"> is there a better way to attach the function to when the window is resized? I am not sure how Opera and Safari return offsetWidth and if they do it like mozilla, or need special values like IE does to make it fit. Thanks for all of your help with any of these 'mini' questions I have a form that allows photos to be uploaded. I am using Perl to do this, and it works fine. Now I want to validate that the size of the image does not exceed a certain limit BEFORE it actually uploads. I can do that in Perl using something like the code below. But, I would rather do this in Javascript. I already have a routine that validates that the image file name does not contain embedded spaces. I would like to add this there. Can this be done in Javascript? Code: if ($ENV{'CONTENT_LENGTH'} > 100000) { print "SIZE EXCEEDS LIMIT!" } Good morning, This is my first post here and if it is in the wrong forum I do apologise. I am looking for help with a navigation element on which my page titles have outgrown the existing navigation. I have considered reducing page titles but know this would only be a short term solution. My web pages can be accessed http://www.eskside.co.uk/ss_rohilla/index.htm here as can my array http://www.eskside.co.uk/ss_rohilla/array.js and menu http://www.eskside.co.uk/ss_rohilla/menu.js I must admit that JS is somewhat complex to me and the basic design was created a long time before we moved and lost contact with friends. If you could assist me I would be most grateful. Colin I have the following code for an embed that I would like to add to my site. However, the embed is too large for the box I am trying to put it in on my social network. I tried to add height/width parameters, but it did not work. Is there a way to modify the size? Thanks!!! <div id="wb-9ez75d"></div><script type="text/javascript" src="http://flockdraw.com/embed/9ez75d"></script> Sup everyone I'm trying to find a script that will automatically resize the height of an iframe depending on the document it contains. I found the script he Code: <!-- function calcHeight() { //find the height of the internal page var the_height= document.getElementById('the_iframe').contentWindow. document.body.scrollHeight; //change the height of the iframe document.getElementById('the_iframe').height= the_height; } //--> The only problem is that although it gets larger when the page changes, it doesn't get smaller. Any one know how to fix this??? hi guys, i am using this script (jquery) to resize textareas when a user enters text. it works well. in the management system im writing i would like to also resize all textareas so that all text is visible when forms load i.e. a user loads a form with textareas on and all the text is visible when they read the contents Code: /* * jQuery autoResize (textarea auto-resizer) * @copyright James Padolsey http://james.padolsey.com * @version 1.04 */ (function($){ $.fn.autoResize = function(options) { // Just some abstracted details, // to make plugin users happy: var settings = $.extend({ onResize : function(){}, animate : true, animateDuration : 150, animateCallback : function(){}, extraSpace : 20, limit: 1000 }, options); // Only textarea's auto-resize: this.filter('textarea').each(function(){ // Get rid of scrollbars and disable WebKit resizing: var textarea = $(this).css({resize:'none','overflow-y':'hidden'}), // Cache original height, for use later: origHeight = textarea.height(), // Need clone of textarea, hidden off screen: clone = (function(){ // Properties which may effect space taken up by chracters: var props = ['height','width','lineHeight','textDecoration','letterSpacing'], propOb = {}; // Create object of styles to apply: $.each(props, function(i, prop){ propOb[prop] = textarea.css(prop); }); // Clone the actual textarea removing unique properties // and insert before original textarea: return textarea.clone().removeAttr('id').removeAttr('name').css({ position: 'absolute', top: 0, left: -9999 }).css(propOb).attr('tabIndex','-1').insertBefore(textarea); })(), lastScrollTop = null, updateSize = function() { // Prepare the clone: clone.height(0).val($(this).val()).scrollTop(10000); // Find the height of text: var scrollTop = Math.max(clone.scrollTop(), origHeight) + settings.extraSpace, toChange = $(this).add(clone); // Don't do anything if scrollTip hasen't changed: if (lastScrollTop === scrollTop) { return; } lastScrollTop = scrollTop; // Check for limit: if ( scrollTop >= settings.limit ) { $(this).css('overflow-y',''); return; } // Fire off callback: settings.onResize.call(this); // Either animate or directly apply height: settings.animate && textarea.css('display') === 'block' ? toChange.stop().animate({height:scrollTop}, settings.animateDuration, settings.animateCallback) : toChange.height(scrollTop); }; // Bind namespaced handlers to appropriate events: textarea .unbind('.dynSiz') .bind('keyup.dynSiz', updateSize) .bind('keydown.dynSiz', updateSize) .bind('change.dynSiz', updateSize); }); // Chain: return this; }; })(jQuery); many thanks for any help |