JavaScript - Javascript Addtext Onclick Assistance Required
Hi, I am constructing a website with a page that holds a world clock.
The clock displays in the centre of the page and is surrounded by 12 buttons (Individual World Cities). OnClick of these buttons changes the time displayed. I am trying to amend the code so that when one of these buttons is clicked. It not only updates and changes the clock. But also adds text below the clock that says something like "The time in New York is now displayed). I have been trying to find the code to do this for a few hours and the closest I could find was an addtext function. No matter what I do though I just cant get it to work! If anyone could help that would be appreciated. I have pasted the Script for the clock below (This code is before I edited it with the addText code). <script> var GMToffset = 0,t; function start() { GMToffset=zxcReadCookie('time')||0; t=setInterval('digitalclock()',500); } function digitalclock() { var today=new Date(); var hours=(today.getHours() + GMToffset*1+24)%24; var minutes=today.getMinutes(); var seconds=today.getSeconds(); minutes=checkTime(minutes); seconds=checkTime(seconds); hours=checkTime(hours); document.getElementById('txt').innerHTML=hours+":"+minutes+":"+seconds; } function checkTime(i) { if (i<10) { i="0" + i; } return i; } function updatetime(nu) { GMToffset = nu; zxcCreateCookie('time',nu,1); // change 1 to the number of days persistance required } function zxcCreateCookie(nme,v,days){ document.cookie=nme+'='+v+';expires='+(new Date(new Date().getTime()+days*86400000).toGMTString())+';path=/'; } function zxcReadCookie(nme){ nme+='='; var split = document.cookie.split(';'); for(var z0=0;z0<split.length;z0++){ var s=split[z0]; while (s.charAt(0)==' ') s=s.substring(1,s.length); if (s.indexOf(nme)==0) return s.substring(nme.length,s.length); } return null; } </script> </head> <body onload="start()"> <div align="center"> <input type="button" onclick="updatetime(-4)" value="Time in Buenos Aires" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime(-5)" value="Time in New York" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime(-8)" value="Time in San Francisco" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /><br> <input type="button" onclick="updatetime(-11)" value="Time in Hawaii" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime(-13)" value="Time in Fiji" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime(-14)" value="Time in Sydney" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /><br><br> <div id="txt"></div> </div> <div align="center"> <input type="button" onclick="updatetime(8)" value="Time in Tokyo" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime(7)" value="Time in Hong Kong" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime(6)" value="Time in Bangkok" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /><br> <input type="button" onclick="updatetime(1)" value="Time in Rome" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime(0)" value="Time in London" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> <input type="button" onclick="updatetime(3)" value="Time in Moscow" style="color: #07c; font-family: Arial; font-size: 12px; height: 20px; width: 250px;" /> </head> Similar TutorialsI am using the Mega Menu from http://www.javascriptkit.com/script/...megamenu.shtml and need some assistance with an adjustment. The menu is working great as provided. However, we have a fairly wide menu layout and I have received comments that it is visually distracting to have the menu fly out horizontally. We want to have the menu start out full width and only animate to drop down vertically. Is this possible? If so, where in jkmegamenu.js would I make this adjustment? Thank you. Paul I have the following regex pattern: var patt=/(&(?=(amp|apos|gt|lt|quot)|[^&])+/; It's validation to ensure that any ampersand sign is followed by amp;, apos;, gt;, lt;, or qout;. It should validate any other character except the aforementioned ampersand case. The regex checks out ok on all online regex testers. however, when i apply it to javascript via the test() method, things that return a fail in the testers return true with the js test() method, so the validation isn't working for me right now in javascript. e.g. var testStr = 'someString&'; //should fail var testStr2 = 'someString&'; //should pass however, calling patt.test(testStr); returns true when it should be returning false... Thanks for any input and help you all have to offer. I've been beating this to death for about 3 hours and I'm a little stuck on it.. I have a javascript code, which initiates via "onClick" when a user clicks on a checkbox. I downloaded the sample code, but the problem is is that I need the javascript to be initiated automatically, not when a user clicks on a checkbox. I would greatly appreciate it if anyone could help me resolve this issue. Below is a sample of the code I'm using. Thanks in advance. Code: <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /> <meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- iPad/iPhone specific css below, add after your main css > <link rel="stylesheet" media="only screen and (max-device-width: 1024px)" href="ipad.css" type="text/css" /> <link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" /> --> <!-- If you application is targeting iOS BEFORE 4.0 you MUST put json2.js from http://www.JSON.org/json2.js into your www directory and include it here --> <script type="text/javascript" charset="utf-8" src="phonegap.0.9.6.min.js"></script> <script type="text/javascript" charset="utf-8" src="SAiOSAdPlugin.js"></script> <script type="text/javascript" charset="utf-8"> // If you want to prevent dragging, uncomment this section /* function preventBehavior(e) { e.preventDefault(); }; document.addEventListener("touchmove", preventBehavior, false); */ var gLastAdLoadedDate = null; var gTotalAdsLoaded = 0; var gTimerId = null; function onBodyLoad() { document.addEventListener("deviceready", onDeviceReady,false); } function onOrientationChange() { //alert(window.orientation); } /* When this function is called, PhoneGap has been initialized and is ready to roll */ function onDeviceReady() { // listen for orientation changes window.addEventListener("orientationchange", window.plugins.iAdPlugin.orientationChanged, false); // listen for the "iAdBannerViewDidLoadAdEvent" that is sent by the iAdPlugin document.addEventListener("iAdBannerViewDidLoadAdEvent", iAdBannerViewDidLoadAdEventHandler, false); // listen for the "iAdBannerViewDidFailToReceiveAdWithErrorEvent" that is sent by the iAdPlugin document.addEventListener("iAdBannerViewDidFailToReceiveAdWithErrorEvent", iAdBannerViewDidFailToReceiveAdWithErrorEventHandler, false); var adAtBottom = false; setTimeout(function() { window.plugins.iAdPlugin.prepare(adAtBottom); // by default, ad is at Top }, 1000); } function iAdBannerViewDidFailToReceiveAdWithErrorEventHandler(evt) { alert(evt.error); window.plugins.iAdPlugin.showAd(false); var elem = document.getElementById("showAd"); elem.checked = false; } function iAdBannerViewDidLoadAdEventHandler(evt) { // if we got this event, a new ad is loaded var elem = document.getElementById("lastAdLoaded"); gLastAdLoadedDate = new Date(); elem.innerHTML = gLastAdLoadedDate.toLocaleString(); elem = document.getElementById("showAd"); elem.disabled = false; elem.checked = true; window.plugins.iAdPlugin.showAd(true); gTotalAdsLoaded++; elem = document.getElementById("totalAdsLoaded"); elem.innerHTML = gTotalAdsLoaded.toString(); if (gTimerId) { clearInterval(gTimerId); } gTimerId = setInterval(lastAdLoadedInterval, 1000); } function lastAdLoadedInterval() { var now = (new Date()).getTime(); var diff = now - gLastAdLoadedDate.getTime(); var elem = document.getElementById("lastAdLoaded"); var ms_in_a_year = 31449600000; /* 1000ms x 60s x 60m x 24hrs x 7d x 52w */ var ms_in_a_week = 604800000; /* 1000ms x 60s x 60m x 24hrs * 7d */ var ms_in_a_day = 86400000; /* 1000ms x 60s x 60m x 24hrs */ var ms_in_an_hour = 3600000; /* 1000ms x 60s x 60m */ var ms_in_a_minute = 60000; /* 1000ms x 60s */ var ms_in_a_second = 1000; var milliseconds = Math.floor(diff); var seconds = Math.floor(milliseconds / ms_in_a_second) % 60; var minutes = Math.floor(milliseconds / ms_in_a_minute) % 60; var hours = Math.floor(milliseconds / ms_in_an_hour) % 24; var days = Math.floor(milliseconds / ms_in_a_day) % 7; var weeks = Math.floor(milliseconds / ms_in_a_week) % 52; var years = Math.floor(milliseconds / ms_in_a_year); var caption = seconds + "s ago"; if (minutes > 0) { caption = minutes + "m " + caption; } if (hours > 0) { caption = hours + "h " + caption; } if (days > 0) { caption = days + "d " + caption; } if (weeks > 0) { caption = weeks + "w " + caption; } if (years > 0) { caption = years + "yr " + caption; } elem.innerHTML = caption; } function showAdClicked(evt) { window.plugins.iAdPlugin.showAd(evt.checked); } </script> </head> <body style="margin:0; padding:0;border:1px solid blue;" onload="onBodyLoad()"> <span style="position:absolute; top:0;"> This is some text at the top of the webview. </span> <br /><br /> <form> <input type="checkbox" id="showAd" name="showAd" disabled="disabled" onclick="showAdClicked(this);">Show iAd</input><br /> <br /> <span>New Ad Loaded: <span id="lastAdLoaded">Waiting.</span></span><br /> <span>Total Ads Loaded: <span id="totalAdsLoaded">None.</span></span> </form> <br /> <span style="position:absolute;bottom:0"> This is some text at the bottom of the webview. </span> </body> </html> The javascript (SoiOSADPLUGIN.JS) that is referenceD in this html page i also pasted below he Code: /** * Constructor */ function SAiOSAdPlugin() { } /** * show - true to show the ad, false to hide the ad */ SAiOSAdPlugin.prototype.orientationChanged = function() { PhoneGap.exec("SAiOSAdPlugin.orientationChanged", window.orientation); } /** * show - true to show the ad, false to hide the ad */ SAiOSAdPlugin.prototype.showAd = function(show) { PhoneGap.exec("SAiOSAdPlugin.showAd", show); } /** * atBottom - true to put the ad at the bottom, false to put the ad at the top */ SAiOSAdPlugin.prototype.prepare = function(atBottom) { if (!atBottom) { atBottom = false; } PhoneGap.exec("SAiOSAdPlugin.prepare", atBottom); } /** * Install function */ SAiOSAdPlugin.install = function() { if ( !window.plugins ) window.plugins = {}; if ( !window.plugins.iAdPlugin ) window.plugins.iAdPlugin = new SAiOSAdPlugin(); } /** * Add to PhoneGap constructor */ PhoneGap.addConstructor(SAiOSAdPlugin.install); I get the code to work when I click the checkbox, and it satisfies my needs, but having a checkbox toggle is not exactly ideal for this function. Is there anyway for me to have the "Onclick" function in this code changed to onload? I dont have much experience with javascript. Please provide javascript to create something like the image below: http://www.coolmicroscope.com/java.jpg Hi gurus, I am developing an application in which I am using a client validation library called "livevalidation". When you attach with the input control it shows a message infront of the text box if you leave it empty. But I want to modify it and want to show a image (cross) infront of the text box and message below text box. Here is the CSS file and html file. ------------------------------------ Code: /********************************* LiveValidation *************************************/ .LV_valid { color:#00CC00; } .LV_invalid { color:#CC0000; } .LV_validation_message { clear: both; text-indent: 166px; height: 22px; line-height: 22px; font-size: 11px; font-weight: bold; } .LV_valid_field, input.LV_valid_field:hover, input.LV_valid_field:active, textarea.LV_valid_field:hover, textarea.LV_valid_field:active, .fieldWithErrors input.LV_valid_field, .fieldWithErrors textarea.LV_valid_field { border: 1px solid #00CC00; } .LV_invalid_field, input.LV_invalid_field:hover, input.LV_invalid_field:active, textarea.LV_invalid_field:hover, textarea.LV_invalid_field:active, .fieldWithErrors input.LV_invalid_field, .fieldWithErrors textarea.LV_invalid_field { border: 1px solid #CC0000; } HTML ------ Code: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script src="livevalidation.js" type="text/javascript"></script> <link href="StyleSheet.css" rel="stylesheet" type="text/css" /> </head> <body> <form id="create_account" action=""> Say hello: <input id="sayHello" type="text" /> <script type="text/javascript"> var sayHello = new LiveValidation('sayHello', { validMessage: 'Hey there!', wait: 500 }); sayHello.add(Validate.Presence, { failureMessage: "Don't just ignore me, I wanna be your friend!" }); </script> </form> </body> </html> For livevalidation javascript (.js) i cannot paste here as its quite big and forums is not allowing me paste it so kindly get it from here which I need to modify. here is the link. ---------------- http://livevalidation.com/javascript..._standalone.js In the above file there is a function called "createMessageSpan" I've tried to modify it as I am sure this is the function which needs to be modified but how to do it that i dont know as i am not a java specialist. Please help I would really appreciate. Josh Hi All, I am using javascript to get the number of rows in my HTML Table by using below code: Code: var oRows = document.getElementById("HTMLTable").getElementsByTagName('tr'); var iRowCount = oRows.length; Later I am using iRowcount in the FOR loop further in my code as below: Code: for(k=1; k<=iRowCount; k++) { ............................ rest of code ........... ............................ } This piece of code is working fine (i.e. it handles the functionalities which is needed) but it also opens a new browser window with the error message "Object Required".I have really no idead why this is happening.Can anyone suggest me the reason for this? Thanks in advance. -Anil Hi guys. I have made a PHP script that queries a database and uses the reponse to display multiple radio boxes (using a while loop). What I would like to do is have the page URI updated when a radiobox is clicked, without the user having to press on a "Submit" button or something. This is where Javascript comes into play. As this is a while loop, there is no specific number of responses or prefixed names. I've found a lot of stuff on Google with functions calling ID's, and then if the ID matches do a predefined response. Of course that wouldn't work in this situation, and to be frank I don't need anything near as complex. What I'm looking to do is call a Javascript function to redirect the page to "...?location=<get location from PHP var>&id=<get ID from checkbox ID/name>". When the page reloads, I can then use the PHP $_GET["id"] function to display data. It sounds SO simple in theory! Can anyone help? What i've done (and failed): Code: echo "<form>"; while ($explode_count_dec > "0"): $while_query = mysql_query("SELECT * FROM printers WHERE ID LIKE '$explodedata[$explode_number]'"); $while_result = mysql_fetch_assoc($while_query); echo "<input type='radio' value='".$explodedata[$explode_number]."' name='printer' onClick='showmore(".$explode_number.")' />".$while_result["Model"]." <BR /> "; ++$explode_number; --$explode_count_dec; endwhile; echo "</form>"; and the JS: Code: <script type="text/javascript"> function showmore($text) { var room = "<?= $get_location; ?>"; window.location = "?location=" + room + "&id=" + <?php $text; ?> // Couldn't do just $text here? I wish I knew JS.. } </script> Hey everyone, I am having troubles with my form not working correctly in IE. I have onclicks for different parts of my site. I am trying to use onclick and divs to make this happen. Can some look at my code and help me out? Thanks/ Code: <script type="text/javascript"> function switchFS(obj) { var fset,i,fsclass; fset=document.getElementsByTagName('fieldset'); fsclass = obj; for ( i=0; i<fset.length; i++) { if ((fset[i].getAttribute('class') != "user") && (fset[i].getAttribute('class') != fsclass)) { fset[i].style.display = "none"; } else { fset[i].style.display = "block"; } } } </script> </head> <body id="submitform"> <div id="container"> <div id="header"> <?php include($dirprefix . "external/include/header.html"); ?> </div><!-- end header --> <div id="maincontent"> <h3> </h3> <?php include($dirprefix . "external/include/menu_inactive.html"); ?> <div id="bodycontent"> <div id="bodyleftcol"> <h4>Contact</h4> <h5>Registration</h5> </div> <div id="bodyrightcol"> <h1 class="formhead">Site Registration</h1> <p>Please register if you are a Zimmer customer, or an agency or designer working on behalf of one. Completing the requested information will enable us to continue to update and improve site content. Please make note of your password for future reference. You will receive an email with your login information.</p> <div id="mainrightcol"> <form name="form" id="register" method="post" action="processregister.php"> <fieldset class="user"> <legend>i am a:</legend> <label><input type="radio" value="Healthcare provider" class="checkbox" name="usertype" onclick="switchFS('healthcare');" /> Healthcare provider</label> <label><input type="radio" value="Agency or designer for a customer" class="checkbox" name="usertype" onclick="switchFS('agency');" /> Agency or designer for a customer</label> <label><input type="radio" value="Independent agency or designer" class="checkbox" name="usertype" onclick="switchFS('agency');" /> Independent agency or designer</label> <label><input type="radio" value="Zimmer employee" class="checkbox" name="usertype" onclick="switchFS('zimmer');" /> Zimmer employee</label> <label><input type="radio" value="Zimmer field representative" class="checkbox" name="usertype" onclick="switchFS('zimmer1');" /> Zimmer field representative</label> <label><input type="radio" value="Media" class="checkbox" name="usertype" onclick="switchFS('user');" /> Media</label> <label><input type="radio" value="Healthcare Author/Publisher" class="checkbox" name="usertype" onclick="switchFS('author');" /> Healthcare Author/Publisher</label> <label><input type="radio" value="Other" class="checkbox" name="usertype" onclick="switchFS('user');" /> Other</label> </fieldset> <fieldset class="zimmer" style="display: none;"> <legend>zimmer information</legend> <!--<label for="businessunit">Zimmer business unit: <input type="text" name="businessunit" value="" required="required" /></label>--> <label for="division">Zimmer business unit: <select name="division"> <option value="">- n/a -</option> <option value="Knees">Knees</option> <option value="Hips">Hips</option> <option value="Extremities">Extremities</option> <option value="Trauma">Trauma</option> </select></label> </fieldset> <fieldset class="zimmer1" style="display: none;"> <legend>zimmer information</legend> <!--<label for="businessunit">Zimmer business unit: <input type="text" name="businessunit" value="" required="required" /></label>--> <label for="distributorship">Zimmer distributorship: <input type="text" name="distributorship" value="" required="required" /></label> </fieldset> I have added the javascript and the section of code where the user picks how they are. Once you click on one of the users in IE the form goes away. i have this line in my code: PHP Code: echo '<a href="" onClick="yesnolist()">Free Chat</a>'; then at the top i have: Code: <? php //have some php here ?> <div class="innerContainer"> <head> <script type="text/JavaScript"> function yesnolist(val) { alert("lakjsd"); var e = confirm('Do you want to send a free chat request?'); if (e == true) { window.location.href = "http://www-rainbowcode-mobi/confirmfreechat.php"; window.location('http://www-rainbowcode-mobi/confirmfreechat.php'); return true; } else return false; } </script> </head> <span class="headings2">CONTACTS</span> //and more code after this echo '<a href="" onClick="yesnolist()">Free Chat</a>'; why is it not doing my onClick()?? please help? thanks I am trying to set a PHP variable but am using the onClick() event handler, which requires JavaScript. See below: [ICODE]<a href="javascript:update('gallery/Fgallery1-1.jpg', 0);" onClick="index_value = 'gallery1-1';"> <img src="gallery/gallery1-1.jpg" alt="Antique Impressions Hardwood Flooring - White Oak" border="0" class="galborders" onMouseOver="alert_msg('Click to view image close up')" onMouseOut="away()"></a><br /></ICODE] The webpage is http://www.hardwood-floor-products.com/gallery1.php. What I am trying to do is to set up a PHP variable, $index, that is equal to "gallery1-1', 'gallery1-2', etc. so that I can use that varialble throughout this module. I also realize that I need to use JavaScript with onClick() but I have had no success. I realize that PHP is servier-side and JavaScript is client-side, but there must be a way to do that. Genia Hi Everyone, Iv got a button in my HTML5 document that when clicked gives an error. The button is coded as follows: Code: <input type="button" onclick="startGame();" value="Play!" /> The startGame function is held in an external JavaScript file. Whenever i run the code and click on the button i get an error that says startGame is not defined. Any ideas? Thanks, Luke I assum the following html code: <div id="id1" onclick="click()">A<div> <div id="id2" onclick="click()">B<div> Do you know how to get ID = id2 when I onclick on A? Hi everyone, I'm a JavaScript newbie and am trying to use it to direct users to a search page based on the values of two drop down boxes. The issue i am having is that the code below works fine on a test page, but not on my test domain (with wordpress theme) and so i was wondering whether there is anything I am doing wrong... Is onclick already defined maybe? I'm not sure how it works to be honest... Code: <script type="text/javascript"> function gosearch() { var breed = document.getElementById('breed').value; var area = document.getElementById('area').value; var site = "http://hairloss-help.net/?s="; var searchurl = site + breed + area; window.location.href = searchurl; } </script> <strong>Breed</strong> <select name="breed" id="breed"> <option value="">> All</option> <option value="Affenpinscher+">Affenpinscher</option> <option value="Afghan+Hound+">Afghan Hound</option> <option value="Airedale+Terrier+">Airedale Terrier</option> <option value="Akita+">Akita</option> <option value="Alaskan+Malamute+">Alaskan Malamute</option> <option value="Alsation+">Alsation</option> <option value="American+Cocker+Spaniel+">American Cocker Spaniel</option> <option value="Anatolian+Karabash+">Anatolian Karabash</option> </select> <strong>Area</strong> <select name="area" id="area"> <option value="all">> All Areas</option> <optgroup label="England"> <option value="Avon">Avon</option> <option value="Bedfordshire">Bedfordshire</option> <option value="Berkshire">Berkshire</option> <option value="Bristol">Bristol</option> <option value="Buckinghamshire">Buckinghamshire</option> <option value="Cambridgeshire">Cambridgeshire</option> <option value="Cheshire">Cheshire</option> <option value="Cleveland">Cleveland</option> <option value="Cornwall">Cornwall</option> </select> <input type="button" name="gobutton" id="gobutton" value="Go!" onclick="gosearch();" /> The domain I'm currently testing this on is http://www.hairloss-help.net. Any help would be much appreciated. Thanks Sam Hi there, I am wondering if it is possible to navigate anchor links using a button onclick event. I want next and previous hit buttons to navigate the already existing hits (#hit1, #hit2, etc.). For instance, I have: Code: <script type="text/javascript"> var numHits = {HITS}-1; function nextHit(){ if(numHits > 0){ numHits--; } return("location.href=" '#hit" + numHits + " ' ");//added spaces for visibility } </script> <input type="button" value=">" onclick="nextHit()" /> I have tried onclick="nextHit();", onclick="nextHit(); return true/false", onclick=" return nextHit()" and a bunch of others, with no luck. I have seen working examples with the href tag (e.g. <a href="#" onclick="func();return false">), but nothing with buttons. I also can't seem to get the working href examples to work on my server. For instance, I cannot get this code to work, it just goes to js_required.html: <a href="js_required.html" onclick="doSomething(); return false;">go</a> function doSomething(){ alert("test"); } It seems so simple, I'm assuming I'm missing something very basic. I would greatly appreciate any help! ~Bobio I'm attempting to modify a facebook app I purchased that allows friends to send gifts to each other. The problem with the program is that when gifts are accepted, they continue to show on the "accept gift" page. I'd like to change it so that after gifts are accepted, they no longer show on that page, preventing the user from wondering "which gifts have I already accepted?" Later, I'd like to also create a reject gift option, but 1st things 1st. The program is written in php, html, and javascript. I decided one solution was to add a new empty column to the sql table called "accepted". When the user presses "accept gift" I'm thinking an onclick event could be used to add a "y" (for yes) to that record in the database. Then modify the code that displays the gifts to only show gifts from the table 'WHERE' accepted is equal to null. My questions a Is this a logical approach? If so, is the process: create a javascript function that updates mysql and call that function with an onclick event? What about sql injection vulnerabilities? I've read a lot about ajax and HTTP request being the way to do things like this, but could not find an example that represented what I want to do. After weeks of reading, I'm still lost. Hi, i have several links which i am trying to add an on click command to which copies a certain code to the clip board so the user can paste the code with out having to manually copy it first. i have this Code: $latest = simplexml_load_file('codes_ending_soon.xml'); foreach ($latest->discount as $discount) { $code = $discount->id; $link = $discount->link; $store = $discount->storeName; $logo = $discount->logo; $details = $discount->details; if($code_count <=4) {?> <div class="code_cont"> <div class="code_logo"><img src="<?php echo $logo?>" alt="<?php echo $store." code"?>" title="<?php echo $store." code"?>" height="32" /></div> <a class="code" href="<?php echo $link?>" title="Click to see related product(s) / retailer and apply code" onclick="window.clipboardData.setData(<?php echo $code?>)"><?php echo $code?></a> <div class="description"><?php echo $details?></div> </div><?php $code_count++; } }?> but when i click on the link nothing seems to copy at least in firefox anyway? can anyone help me please thanks Luke hello everyone, i am new to all this.. i need help regarding.. i am generating text box dynamically(mean it's a multiple select box, depending upon the number you select , it will generate that many text field.) my problem is that i want to assign a calender to the text field generated whenever a user clicks on that text field. i am able to do it for simple text field as onclick="javascript: showCalendar('idname')" but how to do it in this case, where can i declare this ? I am very new Beginner of Javascript.. My query is that 1)I have 2 radio buttons A and B 2)When I click A I want 2 dropdownbox and a button to be displayed 3)When I click B I want 2 dropdownbox to be displayed. 4)Both should be independent Plz tell me the code..for this Okay. So here's what I'm trying to do. I have my landing page to my site and near the bottom I have 4 little 48x48 class divs (for social network link images if you were wondering ). Each Class div has a background style all to it's own. (so in this case 4 different divs with 4 different class names) . What I want to do with the javascript is to have a function(s) that when called on (depending on which div.class was/is clicked on) will open up a lightbox/new page containing the new page (pertaining to the appropriate social network, depending on which class has been clicked on). I don't want to put an <a></a> tag around the div.classes themselves seperately because the landing page itself has 8 different styles, plus the div.classes I would have to hunt down within the site itself. haha Basically in short I want the classes to have seperate links that when clicked upon it calls the function, opens the lightbox (or opens the new tab/page) and loads the appropriate page. Think yall can help me out here? Hi, I want to call a javascript function without having a button click and it is nestled within php. I have the function OpenChat() in my main page - this works fine. I have the below sub page that is called by an onclick event (originally I had the script launch through a button but I am over loading my server at the moment and need to find a different way to call the function). So I tried the below, which doesn't work. The function just isn't working. My script is: PHP Code: <?php session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] !='')){ header ("Location: Welcome.php"); } $SMyPId=$_SESSION['MyPId']; include("dbconnect.php"); $result = mysql_query("SELECT (chatterspace) FROM chat WHERE chatter='{$SMyPId}' AND EndDate IS NULL group by chatterspace"); while($row = mysql_fetch_array($result)){ $oak = $oak . ';' . $row['chatterspace']; } $beach=explode(";",$oak); $divonecount=$beach[1]; $divtwocount=$beach[2]; $divthreecount=$beach[3]; $divfourcount=$beach[4]; $divfivecount=$beach[5]; if($divonecount=='chat1'){ $chat1='full'; }else if($divtwocount=='chat1'){ $chat1='full'; }else if($divthreecount=='chat1'){ $chat1='full'; }else if($divfourcount=='chat1'){ $chat1='full'; }else if($divfivecount=='chat1'){ $chat1='full'; }else if($divonecount=='chat2'){ $chat2='full'; }else if($divtwocount=='chat2'){ $chat2='full'; }else if($divthreecount=='chat2'){ $chat2='full'; }else if($divfourcount=='chat2'){ $chat2='full'; }else if($divfivecount=='chat2'){ $chat2='full'; }else if($divonecount=='chat3'){ $chat3='full'; }else if($divtwocount=='chat3'){ $chat3='full'; }else if($divthreecount=='chat3'){ $chat3='full'; }else if($divfourcount=='chat3'){ $chat3='full'; }else if($divfivecount=='chat3'){ $chat3='full'; }else if($divonecount=='chat4'){ $chat4='full'; }else if($divtwocount=='chat4'){ $chat4='full'; }else if($divthreecount=='chat4'){ $chat4='full'; }else if($divfourcount=='chat4'){ $chat4='full'; }else if($divfivecount=='chat4'){ $chat4='full'; }else if($divonecount=='chat5'){ $chat5='full'; }else if($divtwocount=='chat5'){ $chat5='full'; }else if($divthreecount=='chat5'){ $chat5='full'; }else if($divfourcount=='chat5'){ $chat5='full'; }else if($divfivecount=='chat5'){ $chat5='full'; } $result = mysql_query("SELECT * FROM allusers WHERE PId='{$mulberry}'"); while($row = mysql_fetch_array($result)){ $nosegay=rand(). rand(). rand(). rand(). rand(); $nightshade="{$SMyPId};{$mulberry};{$row['fullname']};{$nosegay}"; $elm=$row['pphoto']; $helmlock=$row['fullname']; } $poplar=$_POST['chat']; if($chat1 !=='full'){ echo '<script type="text/javascript"> function This(){ OpenChat(\'chatheader1.php\',\'chat1\',\'chat=' . $poplar . '\',\'ChatID=0\',\'getDisplayChat1.php\',\'ChatDisplayOne\',\'getThisChat1.php\',\'displaytalkOne\',\'artemis=' . $poplar . '\')"; alert("chat1"); } </script>'; }elseif($chat2 !=='full'){ echo '<script type="text/javascript"> function This(){ OpenChat(\'chatheader2.php\',\'chat2\',\'chat=' . $poplar . '\',\'ChatID=0\',\'getDisplayChat2.php\',\'ChatDisplayTwo\',\'getThisChat2.php\',\'displaytalkTwo\',\'artemis=' . $poplar . '\')"; alert("chat2"); } </script>'; }elseif($chat3 !=='full'){ echo '<script type="text/javascript"> function This(){ OpenChat(\'chatheader3.php\',\'chat3\',\'chat=' . $poplar . '\',\'ChatID=0\',\'getDisplayChat3.php\',\'ChatDisplayThree\',\'getThisChat3.php\',\'displaytalkThree\',\'artemis=' . $poplar . '\')"; alert("chat3"); } </script>'; }elseif($chat4 !=='full'){ echo '<script type="text/javascript"> function This(){ OpenChat(\'chatheader4.php\',\'chat4\',\'chat=' . $poplar . '\',\'ChatID=0\',\'getDisplayChat4.php\',\'ChatDisplayFour\',\'getThisChat4.php\',\'displaytalkFour\',\'artemis=' . $poplar . '\')"; alert("chat4"); } </script>'; }elseif($chat5 !=='full'){ echo '<script type="text/javascript"> function This(){ OpenChat(\'chatheader5.php\',\'chat5\',\'chat=' . $poplar . '\',\'ChatID=0\',\'getDisplayChat5.php\',\'ChatDisplayFive\',\'getThisChat5.php\',\'displaytalkFive\',\'artemis=' . $poplar . '\')"; alert("chat5"); } </script>'; }else{ echo '<script type="text/javascript"> function This(){ alert("You have reached your IM capacity, please close a chat box"); } </script>'; } mysql_close($con); ?> |