JavaScript - Posting Announcement To Website
Hi,
I need to provide the ability for a user to login and make a posting for announcements. I have done some searching and haven't really came up with anything that will work. I am using a script that is external to the web page that will display the message. My idea was to create a Div that contains a multi-line text box within it. I thought it might be possible to use innerHTML to post a message from a form to the web page that has this text box. Is this a good approach or is there a better way? I'm not really asking anyone to code this for me but some suggestions for achieving this task would be greatly appreciated. I am trying to move away from using a CMS for this particular site. Thanks for your help! Rob Similar TutorialsHello all I have written a web page to create XML from user input. The user inputs a series of values, and these are turned into XML using javascript. The way I have done this is to load in a template XML file using an XMLHTTPrequest and append childNodes to it as required. Thus, what I end up with is a variable called "xmldoc" which is an XML document object. (If I do write(xmldoc) the answer I get is [object XMLDocument].) What I would like to do is to be able to save the thing as an xml file. To this end I have been trying to POST it to a php file that might do this, but to no avail; the php file does not seem to recognise it as an XML DOM object. I just can't work out how I might do this, and all suggestions would be gratefully received. Cheers, Chris hello I was wondering if anyone could help me with a site I am working on. I have recieved great help from here before on getting this far but now I need help as to how to post an html form with an if statement. The code I have is Code: if (area == 4) { cost = 4} then I need a form similar to the one below to pop up when the user has submitted their input. Code: if (cost == 4) { <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="L38W9NYYTDHTQ"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1"> </form> } the form is a buy now button linking to paypal. Hi Guys. Trying to pass variables from the javascript into my php script and into my SQL query so i can track the location of the iphone. So far i have... Code: <script type="text/javascript"> function getGPS() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(showGPS, gpsError); } else { gpsText.innerText = "No GPS Functionality."; } } long = position.coords.longitude; lat = position.coords.latitude; function gpsError(error) { alert("GPS Error: "+error.code+", "+error.message); } function showGPS(position) { gpsText.innerHTML = "<?php $long = "".$_GET['long'].""; $lat = "".$_GET['lat'].""; $sqldel = "INSERT INTO `location` (`id` ,`user_id` ,`long` ,`lat`) VALUES (NULL , '$user', '$long','$lat' );"; mysql_query($sqldel) or die(mysql_error()); echo "$long"; echo "$lat"; ?>"; } </script> This gets the coordinates in javascript and the php runs and i get a new record in the database but it doesnt pass the variables from java to php. Anyone know a workaround to get the variables from the iphone to sql on a single page? I want this to run in the background and refresh every now and then so i can track users location. thanks. Adam. Hi everyone! Firstly, im a beginner in Javascript, totally noobie. Much why this is posted! I have found this site: http://www.forswor.com/index.php/data-apis/ And I want to use this to post the server status on my forum/website. How exactly do I do that? I know there are examples and such and I have read and read on that page but I cannot figure out how to do this. I cant just paste: <script type="text/javascript" src="http://www.forswor.com/forswor_services/prod/serverwidget/getSWTORStatusjs.php"> </script> How would I get this to show the information of say for example Bloodworthy server and in text? I tried adding the line document.write(forswor_server_name);, but didnt show up anything - stupid as I am obviously I have no clue what im doing. I can manage html\css and some php but this is new for me, hehe. Thank you so much for reading an idiots post! Most regards, me. Hello, I am very new on JS and Ajax. It does not work correctly. It posts not only form values but also whole form, box etc. eveything. Also form values disappears after a very short time. Why it is like that? My decisive aim is transfer this form values to php and database via ajax. http://fcbk.imeee.org/test.php Thanks in advance.. Hello, There isa demo below. I have a form and select menus. I am posting it ajax post method and loading the same page with load method as you see in codes. There is a random number genarator. I want to change this random number once a click submit. If i do not load the same page this number does not change. Therefore I use both post and load methods like in demo. However when i do like this there is a problem which is random number have been generated twice somtimes. If you click submit button successively you will see that the number on left top corner sometimes changes twice a click. Why it is so and how can i correct it. Thanks in advance and sorry for my bad English Demo: http://fcbk.imeee.org/test.php test.php PHP Code: <?php print_r($_POST['soru']); echo rand(5, 15); ?> <!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" /> <title>Untitled Document</title> <link href="style.css" media="screen" rel="Stylesheet" type="text/css"> <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() { $("#submit").click(function(event){ $.post( "test.php", $("#sorular").serializeArray(), function(data) { $('#results').html(data); } ); $(".arkadaslar").load("test.php?r=1"); }); }); </script> </head> <body> <?php if(!$_POST):?> <?php if($_GET['r']!=1):?> <ul class="arkadaslar"> <?php endif;?> <form name="ss" id="sorular"> <?php for($i = 1; $i <= 4; $i++):?> <table width="100%" border="0" align="left" cellpadding="0" cellspacing="0"> <tr> <td width="70%" align="left" valign="top"></td> <td width="30%" align="left" valign="top"> <label> <select name="soru[]" size="1" id="select"> <option>Give point</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> </label> </td> </tr> </table><br /><br /> <?php endfor; ?> <input id="submit" type="button" value="Submit"> </form> </ul> <?php endif;?> <p><tt id="results"> </tt></p> </body> </html> In order to pass a session Id using the URL This works fine: Code: <h1 id="goHome"><a href="home.php?<?php echo htmlspecialchars(SID); ?>">Inicio</a></h1> The h1 tags are inside little divs like buttoms, so the divs are links to home.php to: Code: function myMenu() { olinkA=document.getElementById("goHome"); //add event... addEvent(oLinkA,'click',goNow); } //this does not work //the home.php has no session at all function goNow() { location.href="home.php?<?php echo htmlspecialchars(SID); ?>"; } Any idea ? how can I send the session ID to the next page using Javascript as a link sender (location.href) ? Thanks I'm not a programmer and I understand very little of it. I have an application with a button that opens up another website. That website requires credentials. I'm currently using window.open to get the url open and passing a variable to the end of the URL, but when I have searched for a good way to get the credentials passed by using post and can't seem to find a solution. I tried xmlhttprequest, but the limitation of cross-domains is huge because I will have external clients connecting to the database and don't think that asking them to lower the security settings in IE would be a good way to do it. All I need is the ability to click on the button, pass the username and password and have the url open to desired page. I posted the code of the application in another thread, but all I'm getting are just views. Please help. thanks.
Hi all, I've written the following script: Code: <!doctype html> <html> <head> <meta charset="utf-8"> <title>Keys2</title> <script type="text/javascript"> function keyPress(key){ document.getElementById('rect01').style.fill = "red"; } </script> <style> .button { width: 100px; padding-right:10px; height:2em; background-color:#FC3; border-radius:3px; color:#fff; font-weight:bold; } ul { list-style-type: none; padding: 0; margin-left:25px; } li { float:left; width:30px; margin-right:25px; padding:10px; height:2em; background-color:#FC3; font-size:xx-large; } </style> </head> <body> <div> <svg width="1000" height="200"> <rect x="25" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect01"/> <rect x="100" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect02"/> <rect x="175" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect03"/> <rect x="250" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect04"/> <rect x="325" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect05"/> <rect x="400" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect06"/> <rect x="475" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect07"/> <rect x="550" y="50" fill="#FFFFFF" stroke="#000000" width="50" height="150" id="rect08"/> </svg> </div> <div> <ul> <li><a href="#" class="button" onClick="keyPress(rect01);">A</a></li> <li><a href="#" class="button" onClick="keyPress(rect02);">B</a></li> <li><a href="#" class="button" onClick="keyPress(rect03);">C</a></li> <li><a href="#" class="button" onClick="keyPress(rect04);">D</a></li> <li><a href="#" class="button" onClick="keyPress(rect05);">E</a></li> <li><a href="#" class="button" onClick="keyPress(rect06);">F</a></li> <li><a href="#" class="button" onClick="keyPress(rect07);">G</a></li> <li><a href="#" class="button" onClick="keyPress(rect08);">H</a></li> </ul> </div> </body> </html> Now, I could write a version of the keypress function for each rectangle, but that seems like poor coding. Can anyone point out how I might restructure the function or the code so that I can pass the number in the onClick to the rectangle it refers to? Thanks Hello, Below I have my Small form: Code: <p id="join_our_mailing_list">Join our mailing list</p> <form method="post" name="join" action="#" /> <input type="text" class="input_text" name="join_us_email" id="join_us_email" /> <input type="submit" value="submit" class="button join_us_button" /> </form> Then I have my JS to process this... Code: $(".join_us_button").click(function() { var email = $("#join_us_email").val(); var dataString = 'join_us_email='+ email; if(email=='') { $('p#join_our_mailing_list').replaceWith("<p>Provide email</p>"); } else { $.ajax({ type: "POST", url: "join.php", data: dataString, success: function() { $('p#join_our_mailing_list').replaceWith("<p>Thank you</p>"); } }); } return false; }); }); How and what can I do to allow this form to insert into SQL Database? I'd like to insert into SQL their emailaddress, IP, date and referral page.... Thanks for anyone that can help! Hello All, Forgive me if my terminology is off, as I am a Java and PHP newbie, but i will do my best to explain my problems. I am building a simple site for my job and the HTML and CSS is done. I used a simple PHP script to post form data to an SQL table. I wanted to first create a client side form validator to ensure proper data was being entered into the form (First name, last name, phone, email, state, zip code). Data was being posted to the form no problem prior to the Javascript validation. Now that the Javascript validation is in place, no data is passed to the database and only empty records appear in the table when the form is submitted. How do I get Javascript and PHP to play nicely together? I still need to create a server side validation and also a sanitation script to make sure no one tries to inject malicious code, but my main focus now is making sure data can get posted to the database. Please help me out, and correct any incorrect terminology I'm using. This is my form: Code: <form name="form1" id="form1" "method="post" action="insert.php"> <table width="80%" border="0"> <tr> <td align="right">First Name : </td> <td><input type="text" name="fname" style="width:170px;"></td> </tr> <tr> <td align="right">Last Name : </td> <td><input type="text" name="lname" style="width:170px;"></td> </tr> <tr> <td align="right">Phone : </td> <td class=><input type="text" name="phone" style="width:100px;"> </td> </tr> <tr> <td align="right">Email : </td> <td> <input type="text" name="email" style="width:170px;"></td> </tr> <tr> <td align="right">State : </td> <td><select name="state" style="width:150px;"> <option value="000" selected="selected">Select</option> <option value="Alabama">Alabama</option> <option value="Alaska" >Alaska</option> <option value="Arizona" >Arizona</option> <option value="Arkansas" >Arkansas</option> <option value="California" >California</option> <option value="Colorado" >Colorado</option> <option value="Connecticut" >Connecticut</option> <option value="Delaware" >Delaware</option> <option value="District-of-Columbia" >District of Columbia</option> <option value="Florida">Florida</option> <option value="Georgia" >Georgia</option> <option value="Hawaii" >Hawaii</option> <option value="Idaho" >Idaho</option> <option value="Illinois" >Illinois</option> <option value="Indiana" >Indiana</option> <option value="Iowa" >Iowa</option> <option value="Kansas" >Kansas</option> <option value="Kentucky" >Kentucky</option> <option value="Louisiana" >Louisiana</option> <option value="Maine" >Maine</option> <option value="Maryland" >Maryland</option> <option value="Massachusetts" >Massachusetts</option> <option value="Michigan" >Michigan</option> <option value="Minnesota" >Minnesota</option> <option value="Mississippi" >Mississippi</option> <option value="Missouri" >Missouri</option> <option value="Montana" >Montana</option> <option value="Nebraska" >Nebraska</option> <option value="Nevada" >Nevada</option> <option value="New-Hampshire" >New Hampshire</option> <option value="New-Jersey" >New Jersey</option> <option value="New-Mexico" >New Mexico</option> <option value="New-York" >New York</option> <option value="North-Carolina" >North Carolina</option> <option value="North-Dakota" >North Dakota</option> <option value="Ohio" >Ohio</option> <option value="Oklahoma" >Oklahoma</option> <option value="Oregon" >Oregon</option> <option value="Pennsylvania" >Pennsylvania</option> <option value="Rhode-Island" >Rhode Island</option> <option value="South-Carolina" >South Carolina</option> <option value="South-Dakota" >South Dakota</option> <option value="Tennessee" >Tennessee</option> <option value="Texas" >Texas</option> <option value="Utah" >Utah</option> <option value="Vermont" >Vermont</option> <option value="Virginia" >Virginia</option> <option value="Washington" >Washington</option> <option value="West-Virginia" >West Virginia</option> <option value="Wisconsin" >Wisconsin</option> <option value="Wyoming" >Wyoming</option> </select> </td> </tr><tr> <td align="right">Zip Code: </td> <td><input type="text" name="zcode" style="width:50px;"></td> </tr> <tr> <td> </td> <input type="hidden" name="submitted" value="1"> <td><input type="submit" value="Submit" name="submit"></td> </tr> </table> </form> This is my javascript code that links to an external .js file: Code: <script type="text/javascript"> var frmvalidator = new Validator("form1"); frmvalidator.addValidation("fname","req","Please enter your First Name"); frmvalidator.addValidation("fname","minlen=2","Minimum length for First Name is 2 characters"); frmvalidator.addValidation("fname","maxlen=20","Max length for First Name is 20 characters"); frmvalidator.addValidation("lname","req","Please enter your Last Name"); frmvalidator.addValidation("lname","minlen=2","Minimum length for Last Name is 2 characters"); frmvalidator.addValidation("lname","maxlen=20","Max length for Last Name is 20 characters"); frmvalidator.addValidation("email","req","Please enter a Valid Email Address"); frmvalidator.addValidation("email","maxlen=50"); frmvalidator.addValidation("phone","req","Please enter your 10-digit Phone Number. Example: 5051234567"); frmvalidator.addValidation("phone","minlen=10","Please enter your 10-digit Phone Number. Example: 5051234567"); frmvalidator.addValidation("phone","maxlen=10","Please enter your 10-digit Phone Number. Example: 5051234567"); frmvalidator.addValidation("phone","numeric"); frmvalidator.addValidation("state","dontselect=000","Please select your state"); frmvalidator.addValidation("zcode","req","Please enter your 5-digit Zip Code"); frmvalidator.addValidation("zcode","minlen=5","Please enter your 5-digit Zip Code"); frmvalidator.addValidation("zcode","maxlen=5","Please enter your 5-digit Zip Code"); </script> This is my insert.php file that form uses: PHP Code: <?php $con = mysql_connect("localhost","**********","**********"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("sms2011_leads", $con); $sql="INSERT INTO sms2011_prospects (fname, lname, phone, email, state, zcode) VALUES ('$_POST[fname]','$_POST[lname]','$_POST[phone]','$_POST[email]','$_POST[state]','$_POST[zcode]')"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<script>window.location = 'http://www.nationalcollegesearch.org/thankyou.html';</script>"; mysql_close($con) ?> Hi, I found this piece of code online and it's awesome for using the method "post". Code: <form method='POST' action='http://www.google.com/index.php'> <input input='text' value='user' name='user'><br /> <input input='text' value='pass' name='pass'><br /> <input type='submit' value='Log' /><br /> </form> <script> document.forms[0].submit() </script> But there is a litle problem that i'm unable to fix... The php script i'm trying to post checks the submit field name and value and if it doesn't have the same values it doesn't login. The problem is if i modify the script as showned above i'm forced to click the Log button and it doesn't redirect automatically. Code: <form method='POST' action='http://www.google.com/index.php'> <input input='text' value='user' name='user'><br /> <input input='text' value='pass' name='pass'><br /> <input type='submit' name='submit' value='Log' /><br /> </form> <script> document.forms[0].submit() </script> I know that it's a small fix but i can't figure out what!!!! Thanks for all the help provided delete this
I am trying to create a comments posting feature in my site using javascript However everytime i click on submit it shows the comment posted for a second and then the comment dissapears. It does not retain the comment posted. Please help. code is given below: Code: <html> <head> <script type="text/javascript"> function post(){ document.getElementById("label").innerHTML=document.hello.posted.value; } </script> </head> <body> <form name="hello"> <div id="label"> </div> <textarea name="posted"> </textarea> <input type="submit" value="Submit" onclick="post()"> </form> </body> </html> I have a JQuery autosuggest working properly on my form.php page... Now I want to get my form to actual POST the input values. So currently if I just run search.php, I get the following (using echo json_encode): {"label":"Henry Gale","value":"henrygale@gmail.com"},{"label":"Amy Gerges","value":"amy@yahoo.com"}, and the list goes on. So since the search is working properly. Now, I want to POST only the values that I place in the form's input field. I currently have: Code: <script> $(document).ready(function() { $( "#autocomp" ).autoSuggest("search.php", { minChars: 2, selectedItemProp: "label", searchObjProps: "label", selectedValuesProp: "value", selectionLimit: 8, formatList: function(data, elem){ var my_image = data.image ; var my_label = data.label; var new_elem = elem.html(my_image + my_label); return new_elem; } }); }); </script> <input name="contacts" type="text" id="autocomp" maxlength="35" /> But if I do an echo of the $_POST['contacts'] I just get the word: Array I am doing something wrong, just not sure what... Since my input gets a list of comma separated values, how can I: 1) make sure the input values get the "value" attribute which corresponds to the emails. 2) post the emails so I can do things with the emails (run them through format checks, insert them into a mysql db, etc). I've made a ajax chat system. Works fine all browser but opera. Opera seems to have a problem with double posting the same message over and over again. I can't seem to figure out why it's doing this. Is it a known opera bug? So the way the chat works is that you type in your message, your press enter, it then sends it to the server so that it can later be fetched by ajax to append it to the chat window. This seems to all work fine with all browser but opera. Please note that my Javascript isn't the best in the world, so any comments about the way I'm coding it and pointing out errors in my code would be awesome. Maybe someone here can explain to me why this is happening. Here is the code. Thanks for anytime spent into looking at this. Code: var refresh_rate = 1000; //Every second var idleTime = 1200000; //20 minutes var prev; function fade(obj, duration, toggle) { this.steps = 300; this.elem = document.getElementById(obj); function fadeIn() { for(var i = 0; i <= 1; i+=(1/this.steps)) { if(document.getElementById && !document.all) { setTimeout("this.elem.style.opacity = "+ i +"", i * duration); } else { setTimeout("this.elem.style.filter='alpha(opacity="+ i * 102 +"'", i * duration); } } } function fadeOut() { for(var i = 0; i <= 1; i+=(1/this.steps)) { if(document.getElementById && !document.all) { setTimeout("this.elem.style.opacity = "+ (1-i) +"", i * duration); } else { setTimeout("this.elem.style.filter='alpha(opacity="+ (1-i) * 102 +"'", i * duration); } } } /* One for Fade in and anything will be fade out*/ if(toggle == 1) { fadeIn(); } else { fadeOut(); } } function $(elem) { var obj = document.getElementById(elem); if(!obj) return; return obj; } function addEvent(elem, typ, func) { var obj = document.getElementById(elem); if(document.getElementById && !document.all) { obj.addEventListener(typ, func, false); } else if(document.all) { obj.attachEvent("on"+typ, func); } } var http = createAjax(); function createAjax() { if(!this.http && window.ActiveXObject) { try { this.http = new ActiveXObject("Msxml2.XMLHTTP" || "Microsoft.XMLHTTP"); } catch(e1) { this.http = false; } } if(!this.http && window.XMLHttpRequest) { try { this.http = new XMLHttpRequest(); } catch(e2) { alert("Sorry we was unable to make a request between your browser."); } } return this.http; } function cancelInterval() { this.canInterval = window.setTimeout("stopInterval();", idleTime); } function stopInterval() { window.clearInterval(this.refreshChat); this.refreshChat = null; this.canInterval = null; var sp = document.createElement("span"); sp.style.cssText = "color:#D83E3E; font-size:0.8em; font-style:italic;"; sp.setAttribute("id","idleMsg"); sp.innerHTML = 'Your chat has gone idle.'; $('chat-window').appendChild(sp); $('chat-window').scrollTop = $('chat-window').scrollHeight; fade('idleMsg',1000,1); } function canTimeout() { window.clearTimeout(this.canInterval); this.canInterval = null; } function startRefresh() { this.refreshChat = window.setInterval("rh()", refresh_rate); } function pressEnter(e) { if($('textbox').value.length >= 1) { if(this.canInterval) { canTimeout(); } if($('idleMsg')) { $('chat-window').removeChild(document.getElementById('idleMsg')); } var textbox = $('textbox').value; if(e.keyCode == 13) { //press enter http.open('post','scripts/php/chat.php',true); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.send('textbox='+encodeURIComponent(textbox)); $('textbox').value = ''; } if(!this.refreshChat) { startRefresh(); } } } function sendText() { if(this.canInterval) { canTimeout(); } var textbox = $('textbox').value; alert(textbox); var params = 'textbox='+ encodeURIComponent(textbox); http.open('post','scripts/php/chat.php',true); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.setRequestHeader('Content-length', params.length); http.setRequestHeader('Connection','close'); http.send(params); $('textbox').value = ''; if(!this.refreshChat) { startRefresh(); } } var cc = 0; var nm = 0; function rh() { if(!this.canInterval) { cancelInterval(); } var rmd = Math.random(); http.open('get','scripts/php/chat.php?s=true&rmd='+rmd, true); http.send(null); http.onreadystatechange = refresh; function refresh() { var scrollT; ($('expand').innerHTML == 'Expand +') ? scrollT = 133 : scrollT = 233; if(http.readyState == 4 && http.status == 200 && http.responseText != null && http.responseText.length >= 1 && http.responseText != prev) { if(http.responseText == prev) { alert("testing..."); } var span = document.createElement("span"); span.setAttribute("id",cc); span.innerHTML = http.responseText; $('chat-window').appendChild(span); if($('chat-window').scrollTop+36 >= $('chat-window').scrollHeight-scrollT) { $('chat-window').scrollTop = $('chat-window').scrollHeight; } prev = http.responseText; cc++; if(cc >= 70) { //Start removing old chat after 70 messages if($('wel')) { $('chat-window').removeChild(document.getElementById('wel')); } var n = cc - cc+nm; $('chat-window').removeChild(document.getElementById(n)); nm++; } } } } this.refreshChat = window.setInterval("rh()", refresh_rate); function addEvent(elem, typ, func) { var obj = document.getElementById(elem); if(document.getElementById && !document.all) { obj.addEventListener(typ, func, false); } else if(document.all) { obj.attachEvent("on"+typ, func); } } function expand() { var chatWindow = $('chat-window'); var chat = $('chat'); var spanExpand = $('expand'); if(spanExpand.innerHTML == 'Expand +') { chatWindow.style.height='230px'; chat.style.height='300px'; spanExpand.innerHTML = 'Collapse -'; $('chat-window').scrollTop = $('chat-window').scrollHeight; } else { spanExpand.innerHTML ='Expand +'; chatWindow.style.height='130px'; chat.style.height='200px'; $('chat-window').scrollTop = $('chat-window').scrollHeight; } } var i = 0; function fixTextBox(k) { var str = document.getElementById('textbox'); } function changeColor(id) { var colors = new Array(); colors[1] = '#f1f1f1'; colors[2] = '#ff593f'; colors[3] = '#A51792'; colors[4] = '#4E9258'; colors[5] = '#2B65EC'; colors[6] = '#DE954B'; colors[7] = '#36b3e1'; colors[8] = '#FD13DE'; colors[9] = '#6eb361'; var rmd = Math.random(); var params = "c="+id+"&rmd="+rmd; http.open("post","scripts/php/chat.php", true); $('color').style.backgroundColor = colors[id]; http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.setRequestHeader('Content-length', params.length); http.send(params); document.getElementById('colorPicker').removeChild(document.getElementById('colorTree')); document.getElementById('colorPicker').removeChild(document.getElementById('colorBox')); $('textbox').focus(); } function popColors() { if(!$('colorTree') && !$('colorBox')) { var colorBox = document.createElement("div"); colorBox.style.cssText="background:#000000; border:2px solid #333333; width:135px; height:60px; position:absolute; left:8px; bottom:15px; opacity:0.5; filter:alpha(opacity:50); z-index:1;"; colorBox.setAttribute("id","colorBox"); var colorTree = document.createElement("div"); colorTree.setAttribute("id","colorTree"); colorTree.innerHTML = "<span style=\"background:#f1f1f1; cursor:pointer; float:left; width:15px; height:15px; margin:2px;; display:block;\" title=\"White\" onclick=\"changeColor(1)\"></span> <span style=\"background:#ff593f; cursor:pointer; float:left; width:15px; height:15px; margin:2px;; display:block;\" onclick=\"changeColor(2)\" title=\"Red\"></span> <span style=\"background:#A51792; cursor:pointer; float:left; width:15px; height:15px; margin:2px;; display:block;\" onclick=\"changeColor(3)\" title=\"Purple\"></span> <span style=\"background:#4E9258; cursor:pointer; float:left; width:15px; height:15px; margin:2px;; display:block;\" onclick=\"changeColor(4)\" title=\"Green\"></span> <span style=\"background:#2B65EC; cursor:pointer; float:left; width:15px; height:15px; margin:2px;; display:block;\" onclick=\"changeColor(5)\" title=\"Blue\"></span> <span style=\"background:#DE954B; cursor:pointer; float:left; width:15px; height:15px; margin:2px;; display:block;\" onclick=\"changeColor(6)\" title=\"Orange\"></span> <span style=\"background:#36b3e1; cursor:pointer; float:left; width:15px; height:15px; margin:2px;; display:block;\" onclick=\"changeColor(7)\" title=\"Teal\"></span> <span style=\"background:#FD13DE; cursor:pointer; float:left; width:15px; height:15px; margin:2px;; display:block;\" onclick=\"changeColor(8)\" title=\"Pink\"></span> <span style=\"background:#6eb361; cursor:pointer; float:left; width:15px; height:15px; margin:2px;; display:block;\" onclick=\"changeColor(9)\" title=\"Lime Green\"></span>"; $('colorPicker').appendChild(colorTree); $('colorPicker').appendChild(colorBox); } else { document.getElementById('colorPicker').removeChild(document.getElementById('colorTree')); document.getElementById('colorPicker').removeChild(document.getElementById('colorBox')); $('textbox').focus(); } } function popColorsClose() { if($('colorTree') && $('colorBox')) { document.getElementById('colorPicker').removeChild(document.getElementById('colorTree')); document.getElementById('colorPicker').removeChild(document.getElementById('colorBox')); $('textbox').focus(); } } Hi all, I have a small message board with TinyMCE (WYSIWYG) editor integrated into it. It works fine for everything except when someone tries to post code... especially content with the < or > characters. For example, a person may try to post an example of how to make red text in HTML. But when he does this: <span style="color:#ff0000;">Hello</span> Of course it comes out like this: Hello Or C code... #include <stdio.h> gets stripped off as INVALID HTML! So, I ended up making a Javascript filter that pre-processes pasted data and turns all < characters into "‹" and all > into "›" characters. BTW, those two characters look very similar to < and >. They look like this: ‹ and › so that, for example: ‹span style="color:#ff0000;"›Hello‹/span› is NOT interpreted as HTML. Similarly, I pre-convert <br /> to "↵" which is a little "down/left/arrow" symbol that is on most ENTER keys on a keyboard. After converting all the < and > characters, I then restore the ↵ back to <br /> (I do this to preserve the < and > in the br!). The resulting text is posted verbatim as a message, but if it's placed in a CODEBOX, then the codebox does an "onfocus="fix-it-back" meaning that the codebox innerHTML is converted back to < and > characters so it can be selected and copied as real code. All this seems to me to be complicated and convoluted. My gut tells me there is a simpler, better way to do it. Any suggestions or ideas please? Will be appreciated! Thanks! -- Roger ok i need a bit of advice.. I have a webpage and i want to put a section of another website on to my own website.. The Section i want to put on my website is on this page www.bebo.com/thegaadiscos and i only want to put the section with the comments on it... What i want is a bit like the face book section of this website http://www.alexandraburkeofficial.com/ How would this be done does anyone know.. print "<Font face=\"calibri, Arial\"><table id=\"rnatable\" border=2px width=100%>"; print "<th></th>"; print "<th>a</th>"; print "<th>b</th>"; print "<th>c</th>"; print "<th>d</th>"; print "<th>e</th>"; print "<th>f</th>"; print "<th>g</th>"; while($array = mysql_fetch_array($sql_query)) { $id=$array['a']; print "<tr id=\"newtr\">"; print "<td><input id=\"check\" type=\"checkbox\" name=\"keyword[]\" value=\"$id\" ></td>"; print "<td>".$array['a']."</td>"; print "<td>".$array['b']."</td>"; print "<td>".$array['c']."</td>"; print "<td>".$array['d']."</td>"; print "<td>".$array['e']."</td>"; print "<td>".$array['f']."</td>"; print "<td> <a href=\"http://localhost/rnasearch/retrieve.php?a=$id\">bla</a> </td></tr></font>"; } print "</table>"; } this is part of a php searchengine script that i wrote to retrieve data from a database and as you can see the last column that is g contains a link which when clicked takes the user to the second php script which retrieves additional information of that entry, but this is done for only single entries so as you can see i introduced checkboxes so that the user can check any number of checkboxes and retrieve information as per their wish now to do this i created a <input type=text where i want the value of these checkboxes i.e. $id to be posted in a delimited format so that the user can then click the corresponding button and retrieve the information this is the code <div id="floatMenu"> <ul class="menu1"> <center><li><form name="senddata" method="POST" action="http://localhost/retrieve.php" style="display:inline;"><input id="fasta" type="text" class="multitext"><input name="Fasta" type="Submit" value="Retrieve Fasta"></form> this is a css floating menu....so far so good....everything went fine.... after this i had to write a javascript to do this and i've been stuck there searching forums for the last 4 days! this is the javascript i found from somewhere which came close to doing wht i wanted it to do window.onload = function () { var cb = document.getElementById('check'); var fasta = document.getElementById('fasta'); cb.onclick = function () {fasta.value = cb.value + ","; };}; this script only sends the value of the first checkbox in the table, the others are not found by it, mind you its not the first checkbox selected its the first checkbox that is present in the table how can i resolve this problem so that even if i have n number of checkboxes in my table, if the user chooses to do so they can retrieve n number of information....please help i've almost lost hope in this! Hello everyone, i am having a few problems with my form and i was hoping someone can help me understand what i am doing wrong. I'm new to java and scripting for forms. Usually i use Simfatic Forms to build my forms but this form requires special coding and work. I'm build a 5 table form with a dynamically add and remove function that will allow the user to add more Rows to the form. What i would like the add function to do is allow my users to pick from a Dropdown menu how many rows they would like to add to the form from 1,5,10,15,20,25 rows. I have gotten the form to allow the add function of one row only but i cant get the add function to allow the select from list. when the row repeats it wont repeat the datepicker to a workable map or the number system from 5+ in table ren5 i have the page up on my site for testing purposes so you can see what is going on. Another issue im having is when i submit the form to my formtools it takes all the input info and puts it in one line in the datebase. What im trying to do is have each table submit to its own row in the datebase. What im looking for is help understanding what i need to do to make this work. I have been reading a lot of tutorials and have been searching a lot of help sites but everything i have read and tried so far will not work for what im trying to do. I really need help getting this to work in the next couple of days. Here is the link to the page on my server so you can see what is going on.http://www.poweronlydispatch.com/FastPostLoad.html Any help would be very helpful. Thank you all in-advance for your help and understanding off my problem. Here is the first part of the code 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="development-bundle/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css"> <SCRIPT language="javascript"> function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var colCount = table.rows[0].cells.length; for(var i=0; i<colCount; i++) { var newcell = row.insertCell(i); newcell.innerHTML = table.rows[0].cells[i].innerHTML; //alert(newcell.childNodes); switch(newcell.childNodes[0].type) { case "text": newcell.childNodes[0].value = ""; break; case "checkbox": newcell.childNodes[0].checked = false; break; case "select-one": newcell.childNodes[0].selectedIndex = 0; break; } } } function deleteRow(tableID) { try { var table = document.getElementById(tableID); var rowCount = table.rows.length; for(var i=0; i<rowCount; i++) { var row = table.rows[i]; var chkbox = row.cells[0].childNodes[0]; if(null != chkbox && true == chkbox.checked) { if(rowCount <= 1) { alert("Cannot delete all the rows."); break; } table.deleteRow(i); rowCount--; i--; } } }catch(e) { alert(e); } } </SCRIPT> <script src="development-bundle/jquery-1.6.2.js"></script> <script src="development-bundle/ui/jquery.ui.core.js"></script> <script src="development-bundle/ui/jquery.ui.widget.js"></script> <script src="development-bundle/ui/jquery.ui.datepicker.js"></script> <link rel="stylesheet" href="development-bundle/demos/demos.css"> <script> $(function() { $( "#datepicker" ).datepicker({ showOn: "button", buttonImage: "development-bundle/demos/images/calendar.gif", buttonImageOnly: true }); $( "#datepicker1" ).datepicker({ showOn: "button", buttonImage: "development-bundle/demos/images/calendar.gif", buttonImageOnly: true }); $( "#datepicker2" ).datepicker({ showOn: "button", buttonImage: "development-bundle/demos/images/calendar.gif", buttonImageOnly: true }); $( "#datepicker3" ).datepicker({ showOn: "button", buttonImage: "development-bundle/demos/images/calendar.gif", buttonImageOnly: true }); $( "#datepicker4" ).datepicker({ showOn: "button", buttonImage: "development-bundle/demos/images/calendar.gif", buttonImageOnly: true }); $( "#datepicker5" ).datepicker({ showOn: "button", buttonImage: "development-bundle/demos/images/calendar.gif", buttonImageOnly: true }); }); </script> <title>Untitled Document</title> </head> <body> <form action="http://www.poweronlydispatch.com/transporters/process.php" method="post" id="FastPostLoad" name="FastPostLoad"> <input type="hidden" name="form_tools_initialize_form" value="1" /> <input type="hidden" name="form_tools_form_id" value="36" /> <table width="100%" cellspacing="0" id="info"> <tr> <th width="20"> </th> <th width="14"> </th> <th width="110">Pickup Date</th> <th width="140">Dispatch Number</th> <th width="120">Trailer Type</th> <th width="80">Pickup City</th> <th width="70">Pickup State</th> <th width="60">Pickup Zip </th> <th width="80">Delivery City</th> <th width="80">Delivery State</th> <th width="60">Delivery Zip</th> <th width="80">Pay Ammount</th> <th width="60">Weight</th> </tr> </table> <table id="ren" width="100%" cellspacing="0"> <tr> <td width="20"><INPUT type="checkbox" name="chk"/></td> <td width="16"> 1 </td> <td width="180"><input type="text" name="datepicker" id="datepicker" size="20"></td> <td width="123"><input name="DispatchNumber" type="text" id="DispatchNumber" size="20"></td> <td width="148"><input name="TrailerType" type="text" id="TrailerType" size="25"></td> <td width="91"><input name="PickupCity" type="text" id="PickupCity" size="15"></td> <td width="89"><select name="PickupState" id="PickupState" size="1"> <option value="AK">AK</option><option value="AL">AL</option><option value="AR">AR</option><option value="AZ">AZ</option><option value="CA">CA</option><option value="CO">CO</option><option value="CT">CT</option><option value="DC">DC</option><option value="DE">DE</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="IA">IA</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="MA">MA</option><option value="MD">MD</option><option value="ME">ME</option><option value="MI">MI</option><option value="MN">MN</option><option value="MO">MO</option><option value="MS">MS</option><option value="MT">MT</option><option value="NC">NC</option><option value="ND">ND</option><option value="NE">NE</option><option value="NH">NH</option><option value="NJ">NJ</option><option value="NM">NM</option><option value="NV">NV</option><option value="NY">NY</option><option value="OH">OH</option><option value="OK">OK</option><option value="OR">OR</option><option value="PA">PA</option><option value="RI">RI</option><option value="SC">SC</option><option value="SD">SD</option><option value="TN">TN</option><option value="TX">TX</option><option value="UT">UT</option><option value="VA">VA</option><option value="VT">VT</option><option value="WA">WA</option><option value="WI">WI</option><option value="WV">WV</option><option value="WY">WY</option></select></td> <td width="90"><input name="PickupZip" type="text" id="PickupZip" size="10"></td> <td width="86"><input name="DeliveryCity" type="text" id="DeliveryCity" size="15"></td> <td width="89"><select name="DeliveryState" id="DeliveryState" size="1"> <option value="AK">AK</option><option value="AL">AL</option><option value="AR">AR</option><option value="AZ">AZ</option><option value="CA">CA</option><option value="CO">CO</option><option value="CT">CT</option><option value="DC">DC</option><option value="DE">DE</option><option value="FL">FL</option><option value="GA">GA</option><option value="HI">HI</option><option value="IA">IA</option><option value="ID">ID</option><option value="IL">IL</option><option value="IN">IN</option><option value="KS">KS</option><option value="KY">KY</option><option value="LA">LA</option><option value="MA">MA</option><option value="MD">MD</option><option value="ME">ME</option><option value="MI">MI</option><option value="MN">MN</option><option value="MO">MO</option><option value="MS">MS</option><option value="MT">MT</option><option value="NC">NC</option><option value="ND">ND</option><option value="NE">NE</option><option value="NH">NH</option><option value="NJ">NJ</option><option value="NM">NM</option><option value="NV">NV</option><option value="NY">NY</option><option value="OH">OH</option><option value="OK">OK</option><option value="OR">OR</option><option value="PA">PA</option><option value="RI">RI</option><option value="SC">SC</option><option value="SD">SD</option><option value="TN">TN</option><option value="TX">TX</option><option value="UT">UT</option><option value="VA">VA</option><option value="VT">VT</option><option value="WA">WA</option><option value="WI">WI</option><option value="WV">WV</option><option value="WY">WY</option></select></td> <td width="90"><input name="DeliveryZip" type="text" id="DeliveryZip" size="10"></td> <td width="88"><input name="PayAmount" type="text" id="PayAmount" size="10"></td> <td width="90"><input name="Weight" type="text" id="Weight" size="10"></td> </tr> </tbody> <tfoot> </tfoot> </table> |