HTML - Filling Select From Javascript/ajax
I have a problem filling select input from javascript/ajax:
the important bits of code: function handleFillList() { if (filledList.readyState == 4) window.document.getElementById('listToFill').innerHTML = filledList.responseText; alert(filledList.responseText); alert(window.document.getElementById('listToFill').innerHTML); One would think, that both alerts would show the same result, but it is not so! The first gives me (only the beggining is important) : <option value=CANADA>CANADA</OPTION><option value=CHINA>CHINA</OPTION><option ...... The second gives me: CANADA</OPTION><OPTION value="CHINA">CHINA</OPTION><OPTION..... why did the begging got lost! And then I don't get the select filled as it should be! Thank you for your help, ales Similar TutorialsHi, I need some help. I am using a script which breaks down the cookie information to retrieve a cookie ID. This ID is then displaying using the following function: Code: <script type="text/javascript">var gac = new gaCookies(); document.write(gac.getUniqueId());</script> I have a form which my site visitors can fill in. On the form there is a text field called CookieID. What i am after, is getting the output of the code above to become the 'value' of the field... I am using the following javascript to populate the filed when the page loads: Code: function initForm(){ document.getElementById("Field110").setAttribute("value", "text_to_display"); } However, this function can only be used to display 'text' not html or a script. Does anyone have any insight as to how this could be done? Any help appreciated! I have some information laid out with a fixed width table in html. It looks fine on a regular monitor. When I display it on a wider monitor, or with a different resolution, I have extra unused space on the right. This, of course, makes sense. The question is: what is the recommended method for allowing the text and images to fill out the rest of the screen width - especially where it will work with different monitors, resolutions and browsers? Thanks. I'm making a small little template for just messing around matching colours, and i've tried putting a vertical navigation bar on the left. I have the div with a <ul> inside of it, but it's not taking up the full width of the div. It's taking up 75% of the div. Does anybody have any answers for it happening? I have posted my code below. HTML Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link href="css/style.css" rel="stylesheet" type="text/css" /> <title>Untitled Document</title> <style type="text/css"> body { background-color: #6698FF; font: 100%/1.4 Verdana, Arial, Helvetica, sans-serif; background: #4E5869; margin: 0; padding: 0; color: #000; } </style> </head> <body> <div id="wrap"> <div id="container"> <div id="header"></div> <div id="sidebar1"> <ul class="nav"> <li><a href="#">Home</a></li> <li><a href="#">Link two</a></li> <li><a href="#">Link three</a></li> <li><a href="#">Link four</a></li> </ul> </div> <div id="content">dfgfdgdfg</div> <div id="sidebar2">sgdsgdfg</div> </div> </div> </body> </html> HTML Code: #wrap { width: 1050px; margin: 0px auto; } ul.nav { list-style: none; border-top: 1px solid #666; } ul.nav li { border-bottom: 1px solid #666; } ul.nav a, ul.nav a:visited { padding: 5px 5px 5px 15px; display: block; text-decoration: none; background: #8090AB; color: #000; } ul.nav a:hover, ul.nav a:active, ul.nav a:focus { background: #6F7D94; color: #FFF; } #container{ width:800px; min-height:700px; margin-left:auto; margin-right:auto; background-color:#5CB3FF; } #header{ } #sidebar1{ width:20%; float:left; background-color:#A0CFEC; } #content{ width:60%; float:left; background-color:#FFFFFF; } #sidebar2{ width:20%; float:left; background-color:#A0CFEC; } The layout of this page I'm making requires a centered table, 800 pixels wide and 100% high. I am having huge problems making it fill the entire height of the page though, it just stops rather than going right to the bottom of the page. It's a 4.01 transistional compliant page if that's relevant. Here's a link to the page. Here's a link to the page (apologies for the file size) link to page I want the dark green center section, and the two side cells with tiled graphics to extend right down to the bottom of the page, regardless of height. The center table with the graphics can stay where it is or vertically center, I don't mind about that. I also need it to have no vertical scrollbar when it's viewed fullscreen. If I remove the doctype, it works fine, but I'm wondering if there's a way to have it vaild for that doctype and still look ok? I've tried everything I can think of and am not turning up anything useful with web searches, if anyone can tell me where I've gone wrong and if this is possible to fix in html, I'd really appreciate it. I can't use CSS, and the doctype has to be as it is, because that's what the specs say (it's for an html class). Thanks for any help. Hello all, I am looking for help with something that I know is pretty simple. http://www.somesite.com/refer.htm?4 Upon loading the page, I want to take the value following '?' and post it inside a text area form on the page. Im very new to html and javascript so im not sure exactly how to achieve this. Thanks for the help. Dear All, I find that I can do that in firefox, ie 9, but not ie 8 and ie 7. anyone knows the answer. HTML Code: <select id="resourceTypeTree" name="resourceTypeTree"> <script type="text/javascript">obj158= new Object;obj158.sid = 158;obj158.seq = 1;obj158.lv = 1;obj158.lvText = "首頁";obj158.upLvSid = 1;obj158.isShown = 1;obj158.isNetvigated = 1;obj158.url = "/cle/landingPage.php";obj158.remarks = "";obj158.lastUpdate = "2011-04-18 16:15:50";obj158.uiNextSeq = 0;obj158.nextSid = 160;</script> <option value="158" onclick=selectClick('tree',obj158); >→首頁</option> <script type="text/javascript">obj3= new Object;obj3.sid = 3;obj3.seq = 2;obj3.lv = 1;obj3.lvText = "語文學習基礎知識";obj3.upLvSid = 1;obj3.isShown = 1;obj3.isNetvigated = 0;obj3.url = "/cle/pages/webSiteReferenceList.php?sid=3&upLvSid=1";obj3.remarks = "";obj3.lastUpdate = "2011-04-18 16:28:05";obj3.uiNextSeq = 7;obj3.nextSid = 160;</script> <option value="3" onclick=selectClick('tree',obj3); >→語文學習基礎知識</option> <script type="text/javascript">obj10= new Object;obj10.sid = 10;obj10.seq = 1;obj10.lv = 2;obj10.lvText = "漢字形音義";obj10.upLvSid = 3;obj10.isShown = 1;obj10.isNetvigated = 0;obj10.url = "/cle/pages/webSiteReferenceList.php?sid=10&upLvSid=3";obj10.remarks = "";obj10.lastUpdate = "2011-03-16 13:46:44";obj10.uiNextSeq = 10;obj10.nextSid = 160;</script> <option value="10" onclick=selectClick('tree',obj10); >→→漢字形音義</option> <script type="text/javascript">obj38= new Object;obj38.sid = 38;obj38.seq = 1;obj38.lv = 3;obj38.lvText = "漢字的演變";obj38.upLvSid = 10;obj38.isShown = 1;obj38.isNetvigated = 1;obj38.url = "/cle/pages/webSiteReferenceList.php?sid=38&upLvSid=10";obj38.remarks = "";obj38.lastUpdate = "2011-03-16 14:25:54";obj38.uiNextSeq = 0;obj38.nextSid = 160;</script> <option value="38" onclick=selectClick('tree',obj38); >→→→漢字的演變</option> <script type="text/javascript">obj39= new Object;obj39.sid = 39;obj39.seq = 2;obj39.lv = 3;obj39.lvText = "字形的正體、俗體、異體";obj39.upLvSid = 10;obj39.isShown = 1;obj39.isNetvigated = 1;obj39.url = "/cle/pages/webSiteReferenceList.php?sid=39&upLvSid=10";obj39.remarks = "";obj39.lastUpdate = "2011-03-16 14:25:54";obj39.uiNextSeq = 0;obj39.nextSid = 160;</script> <option value="39" onclick=selectClick('tree',obj39); >→→→字形的正體、俗體、異體</option> </select> Regards, Man Pak Hong, Dave manpakhong@hotmail.com I really need help on this this is the original code : - Code: <html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <head> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="Andy Moo http://locationdetection.mobi/"> <title>TEST1</title> </head> <body> <div id="geo" class="geolocation_data"></div> <?php include 'geojavascript.php'; ?> </body> </html> I would like to add ajax auto refresh.. to refresh the div link which is something like this : - Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <script src="http://ajax.googleapis.com/ajax/ libs/jquery/1.3.0/jquery.min.js"></script> <script> var auto_refresh = setInterval( function() { $('#geo').fadeOut('slow').load('geojavascript.php').fadeIn("slow"); }, 20000); </script> <meta http-equiv="content-type" content="text/html; charset=windows-1250"> <meta name="generator" content="Andy Moo http://locationdetection.mobi/"> <title>Locator</title> </head> <body> <div id="geo" class="geolocation_data"></div> <?php include 'geojavascript.php'; ?> </body> </html> But, there is something wrong here... instead of refreshing the div.. it refresh html page only.. not the div data.. anyone.. please help me on this ? thanks in advance guys... I'd like to have a newsletter opt-in, but I don't want to move the person to a php page to confirm they're in the system. Is it possible to add them from the same page, and without a page refresh, show them they're added? Hi guys, I have a problem and I really dont know how to solve it: my ajax/php/mysql application has to reload a picture every 5 secs. The image gets overwritten every 5 secs too so you can see in the browser how it changes. It works good in Firefox but in IE, the browser saves the image in the cache and doesnt reload it, so I see every time the same pic, even if it was overwritten!!! the main problem is that the image has to keep its name, so renaming the picture isn't a solution :S Reloading the page isn't a solution neither because i use ajax to reload just the container div. I tried with: <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> and <meta http-equiv="expires" content="-1" > but IE doesnt reload the image!!!!! Please help me if you know any solution... Thanks in advance! Sebastian Breit.- Hi... I am using an application that delivers data in the form of HTML tags (example: ^vst843^). I use these tags in an HTX file which writes to an HTML web page. I'd like to use Ajax to update the tag values without refreshing the page, but from what I understand I must write in Javascript to use Ajax. Am I right about this? If so how can I use the HTML tags coming from my application in this way? Thanks. http://www.walterdecantelupe.co.uk/n...c-content.html I have been working on calling external html files into divs on another page and can't seem to get it right! I can't see what I am doing wring here! Please help. Cheers - Mas The original files are available here http://www.dhtmlgoodies.com/scripts/...ic-content.zip Html HTML Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Ajax dynamic content</title> <style type="text/css"> /* This css is only needed for the demo */ body{ margin:10px; font-size:0.9em; font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif; text-align:center; background-color:#E2EBED; height:100%; } a{ color:#F00; } #mainContainer{ width:760px; margin:0 auto; text-align:left; background-color:#FFF; height:100%; padding-bottom:10px; } #mainContainer .news{ margin:5px; border:1px dotted #555; background-color:#EEE; padding:10px; } #mainContainer img{ float:left; margin:2px; } div#header{ border:0px; background-color:#FFF; padding:0px; margin:0px; height:100px; } h2{ font-size:1.3em; margin-bottom:5px; } p{ margin-top:0px; } .clear{ clear:both; } h2{ color:#000; } #news2{ height:150px; } .header{ padding-left:5px; font-weight:bold; } </style> <script type="text/javascript" src="http://www.walterdecantelupe.co.uk/new/js/ajax.js"></script> <script type="text/javascript" src="http://www.walterdecantelupe.co.uk/new/js/ajax-dynamic-content.js"></script> <script type="text/javascript"> ajax_loadContent('news1','http://www.walterdecantelupe.co.uk/new/external/externalfile1.html'); ajax_loadContent('news2','http://www.walterdecantelupe.co.uk/new/external/externalfile2.html'); ajax_loadContent('news3','http://www.walterdecantelupe.co.uk/new/external/externalfile3.html'); </script> </head> <body> <div id="mainContainer"> <p class="header">The content of the three boxes below are loaded by Ajax(Asyncron Javascript And XML) from external files.</p> <div class="news" id="news1"></div> <div class="news" id="news2"></div> <div class="news" id="news3"></div> </div> </body> </html> Hi everyone. I'm after an image gallery for my site like the one found here . I have found the Ajax image gallerys quite nice, but don't have the ability to scroll through the thumbnails if there is more than, say, 5 displayed. Does anybody know of any similar scripts or whatever to get a better result to the mentioned website. TIA, n00b Daniel Hi, I am designing a small website for a friend and decided to use Ajax on one of the pages: http://122.201.74.87/~natural/treatments.html Problem is in firefox the white background (cell) doesnt extend with the ajax cell so the text just runs down the page over the purple background. But if you look at the page in internet explorer the white background (cell) extends and collapses with the ajax cell like it should. Can someone have a quick look at this and let me know what changes i should make so it works in firefox like it does in IE. PS. Yes the coding is nothing special because it is just a quick site i put together for a friend. Thanks. Hi All, Actually I have to develope a javascript function for moving items from from select box to another select box,I finished that,finally client wants to include a reset button in the same form ,if we click on reset button both select boxes in the form has to store the default values which were at the page loading. Please solve this ..Very Urgent..... Thanks in advance.... ---------- JP. Hi all, I'm trying to make a select choose the text that shows on the page (blue rectangle). Also, when i click the text, it's supposed to copy to some other part of the page. It works when i load the page, but when I change the item in the select, it stops working, and I'm not sure why. Any guesses? Thanks!!! the code is the following: Code: <html lang="en-US"> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { hide = false; set_text(); $('#items').change(function(){ set_text(); }); //hide==true? $('#top_suggestions').hide(600): ''; $('.list').click(function(){ console.log('click'); text=$(this).html(); $(annotation).html(text); }); $('.list').mouseover(function(){ $(this).css('cursor', 'hand'); $(this).css('color', 'red'); }); $('.list').mouseleave(function(){ $(this).css('cursor', 'auto'); $(this).css('color', 'black'); }); function set_text(){ text = ""; id = $('#items').get(0).value; text = $('#'+id).html(); console.log(text); $('#top_suggestions').html(text).show(); } }); </script> <style type="text/css" media="screen"> body { font: 11px arial; } .suggest_link { background-color: #FFFFFF; padding: 2px 6px 2px 6px; } .suggest_link_over { background-color: #3366CC; padding: 2px 6px 2px 6px; } #search_suggest { position: absolute; background-color: #FFFFFF; text-align: left; border: 1px solid #000000; } #top_suggestions { background-color: lightblue; width: 50%; } </style> </head> <body> <h1>THIS PAGE</h1> <!-- table --> <table border="0" width="100%"> <tr> <td valign=top><b> Reas:</b> <!-- annotation pannel --> </td> <td width=100% colspan='2'> <textarea style='width:50%;' name='annotation' rows="2" maxlenght='256' id='annotation'></textarea> </td> </tr> <tr> <td>   </td> <td align=left> <input type='submit' value='Go' style='margin-left: -2px;' ></input> </td> </tr> </table> <hr> <table border="0" width="100%"> <tr> <td valign=top><b> Suggestions:</b> <!-- annotation pannel --> </td> <td width=100% colspan='2'> <select id="items"> <option value="s1">Top 5 MOST used for ALL guy</option> <option value="s2">Top 5 LAST used for ALL guy</option> <option value="s3">Top 5 MOST used for THIS guy</option> <option value="s4">Top 5 LAST used for THIS guy</option> </select> </td> <tr> <td></td> <td> <div id='top_suggestions' >   </div> </td> </tr> </tr> </table> <span id='s1' style='display: none;'> <div class=list>Non curo. Si metrum non habet, non est poema.1 </div> <div class=list>Non curo. Si metrum non habet, non est poema.2 </div> <div class=list>Non curo. Si metrum non habet, non est poema.3 </div> <div class=list>Non curo. Si metrum non habet, non est poema.4 </div> <div class=list>Non curo. Si metrum non habet, non est poema.5 </div> </span> <span id='s2' style='display: none;'> <div class=list>Balaenae nobis conservandae sunt1 </div> <div class=list>Balaenae nobis conservandae sunt2 </div> <div class=list>Balaenae nobis conservandae sunt3 </div> <div class=list>Balaenae nobis conservandae sunt4 </div> <div class=list>Balaenae nobis conservandae sunt5 </div> </span> <span id='s3' style='display: none;'> <div class=list>lalala1 </div> <div class=list>lalala2 </div> <div class=list>lalala3 </div> <div class=list>lalala4 </div> <div class=list>lalala5 </div> </span> <span id='s4' style='display: none;'> <div class=list>The quick brown fox jumps over the lazy dog1 </div> <div class=list>The quick brown fox jumps over the lazy dog2 </div> <div class=list>The quick brown fox jumps over the lazy dog3 </div> <div class=list>The quick brown fox jumps over the lazy dog4 </div> <div class=list>The quick brown fox jumps over the lazy dog5 </div> </span> </body> </html> Hi all! I have two <select>, and, depending on what the user selects in the first one changes the options in the second. For example is the 1st <select> is HONDA, the 2nd <select> will automatically become a list of: ACCORD, CIVIC, etc. But it the 1st is FORD, the 2nd automatically has a list of F-150, MUSTANG, etc -- when the user views it. Is this done in just HTML or do I need a different scripting? If so, would you tell me where I should look? Much appreciated! I have a select list on my site that has around 12 entries in it. The problem is that every 5 entries there is a white space entered into the list that I do not want to be there. The only white space I wanted was the very first option I wanted to be white space for a default not entered option in the select list. Does anyone know how to make this problem go away? Hi, I have one select box and for that 30 options are there, but i need to display only 5 with vertical scroll bars when user clicks on select box. How is it possible? Please help. Hi all, I have a select box in an html form which simply doesn't appear in ie6. I dont know what is relevant to this problem, but loosely, the layout is as follows: <div id="content"> <form> <p class="label"><label for="allocation">Label</label></p> <p class="input"><select name="allocation" id="allocation"> <option value="0">option1</option> ... </select> <div class="clear"></div> </form> </div> the label paragraph is floated left and input floated right, clear simply clears the floats. Other things in the form include tinyMCE textareas and textboxes. The submit button has an onclick handler that validates before returning true or false for php to put values into a mysql database. Everything else works fine but the select box is simply not there in ie6. Any help would be greatly appreciated, Thanks, Conrad |