Search Results

Search found 2007 results on 81 pages for 'getelementbyid'.

Page 9/81 | < Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >

  • It is only uploading first row's file input

    - by user1304328
    I have a application which you can access here. If you open the application please click on the "Add" button a couple of times. This will add a new row into a table below. In each table row there is an AJAX file uploader. Now the problem is that if I click on the "Upload" button in any row except the first row, then the uploading only happens in the first row so it is only uploading the first file input only. Why is it doing this and how can I get it so that when then the user clicks the "Upload" button, the file input within that row of the "Upload" button is uploaded and not the first row being uploaded? Below is the full code where it appends the file AJAX file uploaded in each table row: function insertQuestion(form) { var $tbody = $('#qandatbl > tbody'); var $tr = $("<tr class='optionAndAnswer' align='center'></tr>"); var $image = $("<td class='image'></td>"); var $fileImage = $("<form action='upload.php' method='post' enctype='multipart/form-data' target='upload_target' onsubmit='startUpload();' >" + "<p id='f1_upload_process' align='center'>Loading...<br/><img src='Images/loader.gif' /><br/></p><p id='f1_upload_form' align='center'><br/><label>" + "File: <input name='fileImage' type='file' class='fileImage' /></label><br/><label><input type='submit' name='submitBtn' class='sbtn' value='Upload' /></label>" + "</p> <iframe id='upload_target' name='upload_target' src='#' style='width:0;height:0;border:0px solid #fff;'></iframe></form>"); $image.append($fileImage); $tr.append($image); $tbody.append($tr); } function startUpload(){ document.getElementById('f1_upload_process').style.visibility = 'visible'; document.getElementById('f1_upload_form').style.visibility = 'hidden'; return true; } function stopUpload(success){ var result = ''; if (success == 1){ result = '<span class="msg">The file was uploaded successfully!<\/span><br/><br/>'; } else { result = '<span class="emsg">There was an error during file upload!<\/span><br/><br/>'; } document.getElementById('f1_upload_process').style.visibility = 'hidden'; document.getElementById('f1_upload_form').innerHTML = result + '<label>File: <input name="fileImage" type="file"/><\/label><label><input type="submit" name="submitBtn" class="sbtn" value="Upload" /><\/label>'; document.getElementById('f1_upload_form').style.visibility = 'visible'; return true; }

    Read the article

  • Boxy Submit Form

    - by jornbjorndalen
    I am using the boxy jQuery plugin in my page to display a form on a clickEvent for the fullCalendar plugin. It is working all right , the only problem I have is that the form in boxy brings up the confirmation dialog the first time the dialog is opened and when the user clicks "Ok" it submits the form a second time which generates 2 events on my calendar and 2 entries in my database. My code looks like this inside fullCalendar: dayClick: function(date, allDay, jsEvent, view) { var day=""+date.getDate(); if(day.length==1){ day="0"+day; } var year=date.getFullYear(); var month=date.getMonth()+1; var month=""+month; if(month.length==1){ month="0"+month; } var defaultdate=""+year+"-"+month+"-"+day+" 00:00:00"; var ele = document.getElementById("myform"); new Boxy(ele,{title: "Add Task", modal: true}); document.getElementById("title").value=""; document.getElementById("description").value=""; document.getElementById("startdate").value=""+defaultdate; document.getElementById("enddate").value=""+defaultdate; } I also use validators on the forms fields: $.validator.addMethod( "datetime", function(value, element) { // put your own logic here, this is just a (crappy) example return value.match(/^([0-9]{4})-([0-1][0-9])-([0-3][0-9])\s([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$/); }, "Please enter a date in the format YYYY-mm-dd hh:MM:ss" ); var validator=$("#myform").validate({ onsubmit:true, rules: { title: { required: true }, startdate: { required: true, datetime: true }, enddate: { required: true, datetime: true } }, submitHandler: function(form) { //this function renders a new event and makes a call to a php script that inserts it into the db addTask(form); } }); And the form looks like this: <form id ='myform'> <table border='1' width='100%'> <tr><td align='right'>Title:</td><td align='left'><input id='title' name='title' size='30'/></td></tr> <tr><td align='right'>Description:</td><td align='left'><textarea id='description' name='description' rows='4' cols='30'></textarea></td></tr> <tr><td align='right'>Start Date:</td><td align='left'><input id='startdate' name='startdate' size='30'/></td></tr> <tr><td align='right'>End Date:</td><td align='left'><input id='enddate' name='enddate' size='30' /></td></tr> <tr><td colspan='2' align='right'><input type='submit' value='Add' /></td></tr> </table> </form>

    Read the article

  • How to read & write contents of a div from localstorage in chrome extensions?

    - by Minas Abovyan
    I am trying to build an extension that will allow users to put some parameters into a text box in the popup, generate a link using that information and add it to the said popup. I have all that working, but needless to say, it gets flushed every time the user opens the extension anew. I'd like the info that has been put in there to stay, but can't seem to get it to work. Here's what I have thus far: manifest.json { "manifest_version": 2, "name": "Test", "description": "Test Extension", "version": "1.0", "permissions": [ "http://*/*", "https://*/*" ], "browser_action": { "default_title": "This is a test", "default_popup": "popup.html" } } popup.html <!DOCTYPE html> <html> <head> </head> <body> <div id="linkContainer"/> <input type="text" id="catsList"/> <button type="button" id="addToList">Add</button> <script src="popup.js"></script> </body> </html> popup.js function addCats() { var a = document.createElement('a'); a.appendChild(document.createTextNode(document.getElementById('catsList').value)); a.setAttribute('href', 'http://google.com'); var p = document.createElement('p'); p.appendChild(a) document.getElementById('linkContainer').appendChild(p); indexLinks() } function indexLinks() { var links = document.getElementsByTagName("a"); for (var i = 0; i < links.length; i++) { (function () { var ln = links[i]; var location = ln.href; ln.onclick = function () { chrome.tabs.create({active: true, url: location}); }; })(); } }; document.getElementById('addToList').onclick = addCats; My guess is that I need something along the lines of localStorage['cointainer'] = document.getElementById('linkContainer'); at the end of addCats() and a call to something like function loadLocalStorage() { var container = document.getElementById('linkContainer'); container.innerHTML = localStorage['container']; } at the beginning, but doing that didn't work. Not sure what's going wrong. Also,if there is a different way to save users' additions, I'd be open to them.

    Read the article

  • how to get the content of iframe in a php variable? [closed]

    - by Sahil
    My code is somewhat like this: <?php if($_REQUEST['post']) { $title=$_REQUEST['title']; $body=$_REQUEST['body']; echo $title.$body; } ?> <script type="text/javascript" src="texteditor.js"> </script> <form action="" method="post"> Title: <input type="text" name="title"/><br> <a id="bold" class="font-bold"> B </a> <a id="italic" class="italic"> I </a> Post: <iframe id="textEditor" name="body"></iframe> <input type="submit" name="post" value="Post" /> </form> the texteditor.js file code is: $(document).ready(function(){ document.getElementById('textEditor').contentWindow.document.designMode="on"; document.getElementById('textEditor').contentWindow.document.close(); $("#bold").click(function(){ if($(this).hasClass("selected")) { $(this).removeClass("selected"); }else { $(this).addClass("selected"); } boldIt(); }); $("#italic").click(function(){ if($(this).hasClass("selected")) { $(this).removeClass("selected"); }else { $(this).addClass("selected"); } ItalicIt(); }); }); function boldIt(){ var edit = document.getElementById("textEditor").contentWindow; edit.focus(); edit.document.execCommand("bold", false, ""); edit.focus(); } function ItalicIt(){ var edit = document.getElementById("textEditor").contentWindow; edit.focus(); edit.document.execCommand("italic", false, ""); edit.focus(); } function post(){ var iframe = document.getElementById("body").contentWindow; } actualy i want to fetch data from this texteditor (which is created using iframe and javascript) and store it in some other place. i'm not able to fetch the content that is entered in the editor (i.e. iframe here). please help me out of this....

    Read the article

  • Merging multiple Google calendar feeds into one JSON object in javascript

    - by Jeramy
    I am trying to bring in the JSON feeds from multiple Google calendars so that I can sort the upcoming events and display the next X number in an "Upcoming Events" list. I have this working with Yahoo! pipes but I want to get away from using a 3rd party to aggregate. I think I am close, but I cannot get the JSON objects created correctly. I am getting the data into the array but not in JSON format, so I can't manipulate it. I have tried var myJsonString = JSON.stringify(JSONData); using https://github.com/douglascrockford/JSON-js but that just threw errors. I suspect because my variable is in the wrong starting format. I have tried just calling the feed like: $.getJSON(url); and creating a function concant1() to do the JSONData=JSONData.concat(data);, but it doesn't fire and I think it would produce the same end result anyway. I have also tried several other methods of getting the end result I want with varying degrees of doom. Here is the closest I have come so far: var JSONData = new Array(); var urllist = ["https://www.google.com/calendar/feeds/dg61asqgqg4pust2l20obgdl64%40group.calendar.google.com/public/full?orderby=starttime&max-results=3&sortorder=ascending&futureevents=true&ctz=America/New_York&singleevents=true&alt=json&callback=concant1","https://www.google.com/calendar/feeds/5oc3kvp7lnu5rd4krg2skcu2ng%40group.calendar.google.com/public/full?orderby=starttime&max-results=3&sortorder=ascending&futureevents=true&ctz=America/New_York&singleevents=true&alt=json&callback=concant1","http://www.google.com/calendar/feeds/rine4umu96kl6t46v4fartnho8%40group.calendar.google.com/public/full?orderby=starttime&max-results=3&sortorder=ascending&futureevents=true&ctz=America/New_York&singleevents=true&alt=json&callback=concant1"]; urllist.forEach(function addFeed(url){ alert("The URL being used: "+ url); if (void 0 != JSONData){JSONData=JSONData.concat($.getJSON(url));} else{JSONData = $.getJSON(url);} alert("The count from concantonated JSONData: "+JSONData.length); }); document.write("The final count from JSONData: "+JSONData.length+"<p>"); console.log(JSONData) UPDATE: Now with full working source!! :) If anyone would like to make suggestions on how to improve the code's efficiency it would be gratefully accepted. I hope others find this useful.: // GCal MFA - Google Calendar Multiple Feed Aggregator // Useage: GCalMFA(CIDs,n); // Where 'CIDs' is a list of comma seperated Google calendar IDs in the format: [email protected], and 'n' is the number of results to display. // While the contained console.log(); outputs are really handy for testing, you will probably waant to remove them for regular usage // Author: Jeramy Kruser - http://jeramy.kruser.me //onerror=function (d, f, g){alert (d+ "\n"+ f+ "\n");} if (!window.console) {console = {log: function() {}};} document.body.className += ' js-enabled'; // Global variables var urllist = []; var maxResults = 3; // The default is 3 results unless a value is sent var JSONData = {}; var eventCount = 0; var errorLog = ""; JSONData = { count: 0, value : { description: "Aggregates multiple Google calendar feeds into a single sorted list", generator: "StackOverflow communal coding - Thanks for the assist Patrick M", website: "http://jeramy.kruser.me", author: "Jeramy & Kasey Kruser", items: [] }}; // For putting dates from feed into a format that can be read by the Date function for calculating event length. function parse (str) { // validate year as 4 digits, month as 01-12, and day as 01-31 str = str.match (/^(\d{4})(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])$/); if (str) { // make a date str[0] = new Date ( + str[1], + str[2] - 1, + str[3]); // check if month stayed the same (ie that day number is valid) if (str[0].getMonth () === + str[2] - 1) { return str[0]; } } return undefined; } //For outputting to HTML function output() { var months, day_in_ms, summary, i, item, eventlink, title, calendar, where,dtstart, dtend, endyear, endmonth, endday, startyear, startmonth, startday, endmonthdayyear, eventlinktitle, startmonthday, length, curtextval, k; // Array of month names from numbers for page display. months = {'0':'January', '1':'February', '2':'March', '3':'April', '4':'May', '5':'June', '6':'July', '7':'August', '8':'September', '9':'October', '10':'November', '11':'December'}; // For use in calculating event length. day_in_ms = 24 * 60 * 60 * 1000; // Instantiate HTML Arrays. summary = []; for (i = 0; i < maxResults; i+=1 ) { //console.log("i: "+i+" < "+"maxResults: "+ maxResults); if (!(JSONData.value.items[i] === undefined)) { item = JSONData.value.items[i]; // Grabbing data for each event in the feed. eventlink = item.link[0]; title = item.title.$t; // Only display the calendar title if there is more than one calendar = ""; if (urllist.length > 1) { calendar = '<br />Calendar: <a href="https://www.google.com/calendar/embed?src=' + item.gd$who[0].email + '&ctz=America/New_York">' + item.author[0].name.$t + '<\/a> (<a href="https://www.google.com/calendar/ical/' + item.gd$who[0].email + '/public/basic.ics">iCal<\/a>)'; } // Grabbing event location, if entered. if ( item.gd$where[0].valueString !== "" ) { where = '<br />' + (item.gd$where[0].valueString); } else { where = (""); } // Grabbing start date and putting in form YYYYmmdd. Subtracting one day from dtend to fix Google's habit of ending an all-day event at midnight on the following day. dtstart = new Date(parse(((item.gd$when[0].startTime).substring(0,10)).replace(/-/g,""))); dtend = new Date(parse(((item.gd$when[0].endTime).substring(0,10)).replace(/-/g,"")) - day_in_ms); // Put dates in pretty form for display. endyear = dtend.getFullYear(); endmonth = months[dtend.getMonth()]; endday = dtend.getDate(); startyear = dtstart.getFullYear(); startmonth = months[dtstart.getMonth()]; startday = dtstart.getDate(); //consolidate some much-used variables for HTML output. endmonthdayyear = endmonth + ' ' + endday + ', ' + endyear; eventlinktitle = '<a href="' + eventlink + '">' + title + '<\/a>'; startmonthday = startmonth + ' ' + startday; // Calculates the number of days between each event's start and end dates. length = ((dtend - dtstart) / day_in_ms); // HTML for each event, depending on which div is available on the page (different HTML applies). Only one div can exist on any one page. if (document.getElementById("homeCalendar") !== null ) { // If the length of the event is greater than 0 days, show start and end dates. if ( length > 0 && startmonth !== endmonth && startday === endday ) { summary[i] = ('<h3>' + eventlink + '">' + startmonthday + ', ' + startyear + ' - ' + endmonthdayyear + '<\/a><\/h3><p>' + title + '<\/p>'); } // If the length of the event is greater than 0 and begins and ends within the same month, shorten the date display. else if ( length > 0 && startmonth === endmonth && startyear === endyear ) { summary[i] = ('<h3><a href="' + eventlink + '">' + startmonthday + '-' + endday + ', ' + endyear + '<\/a><\/h3><p>' + title + '<\/p>'); } // If the length of the event is greater than 0 and begins and ends within different months of the same year, shorten the date display. else if ( length > 0 && startmonth !== endmonth && startyear === endyear ) { summary[i] = ('<h3><a href="' + eventlink + '">' + startmonthday + ' - ' + endmonthdayyear + '<\/a><\/h3><p>' + title + '<\/p>'); } // If the length of the event is less than one day (length < = 0), show only the start date. else { summary[i] = ('<h3><a href="' + eventlink + '">' + startmonthday + ', ' + startyear + '<\/a><\/h3><p>' + title + '<\/p>'); } } else if (document.getElementById("allCalendar") !== null ) { // If the length of the event is greater than 0 days, show start and end dates. if ( length > 0 && startmonth !== endmonth && startday === endday ) { summary[i] = ('<li>' + eventlinktitle + '<br />' + startmonthday + ', ' + startyear + ' - ' + endmonthdayyear + where + calendar + '<br />&#160;<\/li>'); } // If the length of the event is greater than 0 and begins and ends within the same month, shorten the date display. else if ( length > 0 && startmonth === endmonth && startyear === endyear ) { summary[i] = ('<li>' + eventlinktitle + '<br />' + startmonthday + '-' + endday + ', ' + endyear + where + calendar + '<br />&#160;<\/li>'); } // If the length of the event is greater than 0 and begins and ends within different months of the same year, shorten the date display. else if ( length > 0 && startmonth !== endmonth && startyear === endyear ) { summary[i] = ('<li>' + eventlinktitle + '<br />' + startmonthday + ' - ' + endmonthdayyear + where + calendar + '<br />&#160;<\/li>'); } // If the length of the event is less than one day (length < = 0), show only the start date. else { summary[i] = ('<li>' + eventlinktitle + '<br />' + startmonthday + ', ' + startyear + where + calendar + '<br />&#160;<\/li>'); } } } if (summary[i] === undefined) { summary[i] = "";} //console.log(summary[i]); } console.log(JSONData); // Puts the HTML into the div with the appropriate id. Each page can have only one. if (document.getElementById("homeCalendar") !== null ) { curtextval = document.getElementById("homeCalendar"); console.log("homeCalendar: "+curtextval); } else if (document.getElementById("oneCalendar") !== null ) { curtextval = document.getElementById("oneCalendar"); console.log("oneCalendar: "+curtextval); } else if (document.getElementById("allCalendar") !== null ) { curtextval = document.getElementById("allCalendar"); console.log("allCalendar: "+curtextval); } if (curtextval.innerHTML.length < 100) { errorLog += '<div id="noEvents">No events found.</div>'; } for (k = 0; k<maxResults; k+=1 ) { curtextval.innerHTML = curtextval.innerHTML + summary[k]; } if (eventCount === 0) { errorLog += '<div id="noEvents">No events found.</div>'; } if (document.getElementById("homeCalendar") === null ) { curtextval.innerHTML = '<ul>' + curtextval.innerHTML + '<\/ul>'; } if (errorLog !== "") { curtextval.innerHTML += errorLog; } } // For taking in each feed, breaking out the events and sorting them into the object by date function sortFeed(event) { var tempEntry, i; tempEntry = event; i = 0; console.log("*** New incoming event object #"+eventCount+" ***"); console.log(event.title.$t); console.log(event); //console.log("i = " + i + " and maxResults " + maxResults); while(i<maxResults) { console.log("i = " + i + " < maxResults " + maxResults); console.log("Sorting event = " + event.title.$t + " by date of " + event.gd$when[0].startTime.substring(0,10).replace(/-/g,"")); if (JSONData.value.items[i]) { console.log("JSONData.value.items[" + i + "] exists and has a startTime of " + JSONData.value.items[i].gd$when[0].startTime.substring(0,10).replace(/-/g,"")); if (event.gd$when[0].startTime.substring(0,10).replace(/-/g,"")<JSONData.value.items[i].gd$when[0].startTime.substring(0,10).replace(/-/g,"")) { console.log("The incoming event value of " + event.gd$when[0].startTime.substring(0,10).replace(/-/g,"") + " is < " + JSONData.value.items[i].gd$when[0].startTime.substring(0,10).replace(/-/g,"")); tempEntry = JSONData.value.items[i]; console.log("Existing JSONData.value.items[" + i + "] value " + JSONData.value.items[i].gd$when[0].startTime.substring(0,10).replace(/-/g,"") + " stored in tempEntry"); JSONData.value.items[i] = event; console.log("Position JSONData.value.items[" + i + "] set to new value: " + event.gd$when[0].startTime.substring(0,10).replace(/-/g,"")); event = tempEntry; console.log("Now sorting event = " + event.title.$t + " by date of " + event.gd$when[0].startTime.substring(0,10).replace(/-/g,"")); } else { console.log("The incoming event value of " + event.gd$when[0].startTime.substring(0,10).replace(/-/g,"") + " is > " + JSONData.value.items[i].gd$when[0].startTime.substring(0,10).replace(/-/g,"") + " moving on..."); } } else { JSONData.value.items[i] = event; console.log("JSONData.value.items[" + i + "] does not exist so it was set to the Incoming value of " + event.gd$when[0].startTime.substring(0,10).replace(/-/g,"")); i = maxResults; } i += 1; } } // For completing the aggregation function complete(result) { var str, j, item; // Track the number of calls completed back, we're not done until all URLs have processed if( complete.count === undefined ){ complete.count = urllist.length; } console.log("complete.count = "+complete.count); console.log(result.feed); if(result.feed.entry){ JSONData.count = maxResults; // Check each incoming item against JSONData.value.items console.log("*** Begin Sorting " + result.feed.entry.length + " Events ***"); //console.log(result.feed.entry); result.feed.entry.forEach( function(event){ eventCount += 1; sortFeed(event); } ); } if( (complete.count-=1)<1 ) { console.log("*** Done Sorting ***"); output(); } } // This is the main function. It takes in the list of Calendar IDs and the number of results to display function GCalMFA(list,results){ var i, calPreProperties, calPostProperties1, calPostProperties2; calPreProperties = "https://www.google.com/calendar/feeds/"; calPostProperties1 = "/public/full?max-results="; calPostProperties2 = "&orderby=starttime&sortorder=ascending&futureevents=true&ctz=America/New_York&singleevents=true&alt=json&callback=?"; if (list) { if (results) { maxResults = results; } urllist = list.split(','); for (i = 0; i < urllist.length; i+=1 ){ if (urllist[i] === 0){ urllist.splice(i,1);} else{ urllist[i] = calPreProperties + urllist[i] + calPostProperties1+maxResults+calPostProperties2;} } console.log("There are " + urllist.length + " URLs"); urllist.forEach(function addFeed(url){ $.getJSON(url, complete); }); } else { errorLog += '<div id="noURLs">No calendars have been selected.</div>'; output(); } }

    Read the article

  • Post Loading ads - using appendChild to move an IFRAME with text link ads

    - by Prem
    I have changed code around to basically load an add the bottom of the page in a hidden div and attached an onload event handler that called document.getElementById(xxx).appendChild() to take the hidden ad and move it into the right spot in my page. This works GREAT.. however when the ad is a text ad it AFTER i move the ad there is nothing in the rendered Iframe. I did tests to see what it looks like before i move it and sure enough the text links load in the IFRAME but the second i do the appendChild call to move the div that contains the ad i seem to loose the contents of the Iframe. Any ideas whats going on <div id="myad" style="display: none;"> GA_googleFillSlot("MyADSlotName"); </div> <script> window.onload = function() { // leader board document.getElementById('adplaceholder').appendChild(document.getElementById('myAd')); document.getElementById('myAd').style.display = ''; </script> UPDATE: I think what the problem here is that on text ads google writes to the iframe directly inserting the relevant text links where are on other ads it uses the iframe to just point to some src. seems like when i do the appendchild, if there is no "src" set for the iframe after the copy is done the iframe in the new location contains nothing... guess it does a reload on the src? Any way around this??

    Read the article

  • javasript function

    - by user289346
    var curtext="View large image"; function changeSrc() { if(curtext == "View large image"){ document.getElementById("boldStuff").innerHTML ="View small image"; curtext="View small image"; } else{ document.getElementById("boldStuff").innerHTML="View large image"; curtext="View large image"; } } var curimage="cottage_small.jpg"; function changeSrc(){ if(curimage == "cottage_small.jpg"){ document.getElementById("myImage").src="cottage_large.jpg"; curimage="cottage_large.jpg"; } else{ document.getElementById("myImage").src="cottage_small.jpg"; curimage="cottage_small.jpg"; } } </script> </head> <body> <!-- Your page here --> <h1> Pink Knoll Properties</h1> <h2> Single Family Homes</h2> <p> Cottage:<strong>$149,000</strong><br/> 2 bed, 1 bath, 1,189 square feet, 1.11 acres <br/><br/> <a href="#" onclick="changeSrc()"><b id="boldStuff" />View large image</a></p> <p><img id="myImage" src="cottage_small.jpg" alt="Photo of a cottage" /></p> </body> I need help, how to put as one function with two arguments. That means when you click, the image and text both will be change. Thank you! Bianca

    Read the article

  • C# Switch-case Loop for Datagridview cells

    - by Nail Yener
    Hi, I am working on a form with datagridview and webbrowser controls. I have three columns as URL, username and password in datagridview. What I want to do is to automate the login for some websites that I use frequently. For that reason I am not sure if this is the right approach but I created the below code. The problem is with the argument of switch. I will click the row on datagridview and then click the login_button so that the username and password info will be passed to the related fields on the webpage. Why I need a switch-case loop is because all the webpages have different element IDs for username and password fields. As I said, I am not sure if datagridview allows switch-case, I searched the net but couldn't find any samples. private void login_button_Click(object sender, EventArgs e) { switch (dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()) { case "http://www.website1.com": webBrowser1.Document.GetElementById("username").InnerText = dataGridView1.Rows[3].Cells[3].Value.ToString(); webBrowser1.Document.GetElementById("password").InnerText = dataGridView1.Rows[3].Cells[4].Value.ToString(); return; case "http://www.website2.com": webBrowser1.Document.GetElementById("uname").InnerText = dataGridView1.Rows[4].Cells[3].Value.ToString(); webBrowser1.Document.GetElementById("pswd").InnerText = dataGridView1.Rows[4].Cells[4].Value.ToString(); return; } HtmlElementCollection elements = this.webBrowser1.Document.GetElementsByTagName("Form"); foreach (HtmlElement currentElement in elements) { currentElement.InvokeMember("Login"); } }

    Read the article

  • FireFox Toolbar Prefwindow unload/acceptdialog Event to Update the toolbar

    - by Mark
    Hi all, I'm trying to develop a firefox toolbar ;) so my structure is In the options.xul is an PrefWindow which i'm opening over an <toolbarbutton oncommand="esbTb_OpenPreferences()"/> function esbTb_OpenPreferences() { window.openDialog("chrome://Toolbar/content/options.xul", "einstellungen", "chrome,titlebar,toolbar,centerscreen,modal", this);} so in my preferences i can set some checkboxes which indicates what links are presented in my toolbar. So when the preferences window is Closed or the "Ok" button is hitted I want to raise an event or an function which updates via DOM my toolbar. So this is the function which is called when the toolbar is loaded. It sets the links visibility of the toolbar. function esbTB_LoadMenue() { var MenuItemNews = document.getElementById("esbTb_rss_reader"); var MenuItemEservice = document.getElementById("esbTb_estv"); if (!(prefManager.getBoolPref("extensions.esbtoolbar.ShowNews"))) { MenuItemNews.style.display = 'none'; } if (!(prefManager.getBoolPref("extensions.esbtoolbar.ShowEservice"))) { MenuItemEservice.style.display = 'none'; } } So I tried some thinks like adding an eventlistener to the dialog which doesn't work... in the way I tried... And i also tried to hand over the window object from the root window( the toolbar) as an argument of the opendialog function changed the function to this. function esbTB_LoadMenue(RootWindow) { var MenuItemNews = RootWindow.getElementById("esbTb_rss_reader"); var MenuItemEservice = RootWindow.getElementById("esbTb_estv");} And then tried to Access the elements over the handover object, but this also not changed my toolbar at runtime. So what i'm trying to do is to change the visibile links in my toolbar during the runtime and I don't get it how I should do that... thanks in advance

    Read the article

  • Right Click Context Menu Script for iFrame

    - by Ramiz Uddin
    The context of the problem is related to an application which is based on single-page Ajax application which consists of three different panels (iframes). The layout of the page is as follows: _________________________________________________ | | | Frame A | FRAME C |__________________| | | | Frame B | | | | | | | | | | | | | | | The problem is with the context menu (right-click menu) in Frame C. The position of the context menu is not perfectly positioned with the mouse click. Particularly, if you drag and increase the size of the Frame C window. Code snippet: var rightedge = parent.frames["FrameC"].frameElement.clientWidth-event.clientX; var bottomedge = parent.frames["FrameC"].frameElement.clientHeight-event.clientY; if (rightedge < document.getElementById('Menu').offsetWidth) menuCoorX = parent.frames["FrameC"].frameElement.scrollLeft + event.clientX - document.getElementById('Menu').offsetWidth; else menuCoorX = parent.frames["FrameC"].frameElement.scrollLeft + event.clientX; if (bottomedge < document.getElementById('Menu').offsetHeight) menuCoorY = parent.frames["FrameC"].frameElement.scrollTop + event.clientY - document.getElementById('Menu').offsetHeight; else menuCoorY = parent.frames["FrameC"].frameElement.scrollTop + event.clientY; Currently, we need it to work only for IE (7 and 8). Please, help! Thanks.

    Read the article

  • How to combine these two JavaScript functions?

    - by user289346
    var curtext = "View large image"; function changeSrc() { if (curtext == "View large image") { document.getElementById("boldStuff").innerHTML = "View small image"; curtext="View small image"; } else { document.getElementById("boldStuff").innerHTML = "View large image"; curtext = "View large image"; } } var curimage = "cottage_small.jpg"; function changeSrc() { if (curimage == "cottage_small.jpg") { document.getElementById("myImage").src = "cottage_large.jpg"; curimage = "cottage_large.jpg"; } else { document.getElementById("myImage").src = "cottage_small.jpg"; curimage = "cottage_small.jpg"; } } </script> </head> <body> <!-- Your page here --> <h1> Pink Knoll Properties</h1> <h2> Single Family Homes</h2> <p> Cottage:<strong>$149,000</strong><br/> 2 bed, 1 bath, 1,189 square feet, 1.11 acres <br/><br/> <a href="#" onclick="changeSrc()"><b id="boldStuff" />View large image</a></p> <p><img id="myImage" src="cottage_small.jpg" alt="Photo of a cottage" /></p> </body> I need help, how to put as one function with two arguments? That means when you click, the image and text both will be change. Thank you! Bianca

    Read the article

  • Listen to double click not click

    - by Mohsen
    I'm just wondering why click event happening when I dbclick an element? I have this code:(JSBIN) HTML <p id="hello">Hello World</p> JavaScript document.getElementById('hello').addEventListener('click', function(e){ e.preventDefault(); this.style.background = 'red'; }, false); document.getElementById('hello').addEventListener('dbclick', function(){ this.style.background = 'yellow'; }, false); It should do different things for click and double click, but it seems when you double click on the p it catch click event in advance and ignore double click. I tried preventDefault the click event too. How can I listen to just dbclick? UPDATE I had a typo in my code. dbclick is wrong. It's dblclick. Anyway the problem still exist. When user double clicks the click event happens. This is updated code that prove it:(JSBin) document.getElementById('hello').addEventListener('click', function(e){ e.preventDefault(); this.style.background = 'red'; this.innerText = "Hello World clicked"; }, false); document.getElementById('hello').addEventListener('dblclick', function(){ this.style.background = 'green'; }, false);

    Read the article

  • Javascript code works only when the page loads

    - by victor
    I have a page with a dropdown and two textboxes. The javascript code checks to make sure that if the dropdown says Appointment Made or Patient Scheduled, the appropriate text boxes will have dates in them. When the page loads and the drop down shows either of the two above, all works fine but when I change the drop down the script does not work. I have put an alert statament after the third line and do see that when I make a change to patient_status, the variable a gets updated but for some reason the script fails and does not prompt. For example if the page loads and Appointment Made is selected, the script will prompt, but if I change the drop down to Patient Scheduled, it will not prompt. Thank You. function calculate() { a= document.getElementById("EditRecordpatient_status").value; b= document.getElementById("EditRecordSurgery_Date").value; c= document.getElementById("EditRecordConsult_Date").value; alert(a); alert(b); alert(c); if (a=="Appointment Made" && c=="") { alert('You have scheduled a patient for consultation but the consult date is missing!'); return false; } else if (a=="Patient Scheduled" && b=="") { alert('You have scheduled a patient for surgery but the surgery date is missing!'); return false; } else { return true; } } document.getElementById("Mod0EditRecord").onclick=calculate;

    Read the article

  • javascript error handeling

    - by pankaj
    I have a javascript function for checking errors which i am callin on OnClicentClick event of a button. Once it catch a error i want to stop execution of click event . But in my case it always it always executes the onclick event. Following is my function: function DisplayError() { if (document.getElementById('<%=txtPassword.ClientID %>').value.length < 6 || document.getElementById('<%=txtPassword.ClientID %>').value.length > 12) { document.getElementById('<%=lblError.ClientID %>').innerText = "Password length must be between 6 to 12 characters"; return false; } var str = <%=PhoneNumber()%>; if(str.length <10) { alert('<%=phoneNum%>'.length); document.getElementById('<%=lblError.ClientID %>').innerText = "Phone Number not in correct format"; return false; } } button html code: <asp:Button runat="server" Text="Submit" ID="btnSubmit" ValidationGroup="submit" onclick="btnSubmit_Click" OnClientClick="DisplayError()"/> It should not execute the button click event once it satisfies any of the IF condition in javascript function.

    Read the article

  • Javascript: Onload if checkbox is checked, change li class

    - by BoDiE2003
    I have this code on javascript side: function changeSelectionStyle(id) { if(document.getElementById(id).className != 'yes'){ document.getElementById(id).className = 'yes'; } else{document.getElementById(id).className = '';} } And this on html: <ul> <li id="selectedAuthorities-4_1li" class=""> <input type="checkbox" id="selectedAuthorities-4_1" name="selectedAuthorities" value="ROLE_ADD_COMMENT_TO_CV" checked="checked" onload="changeSelectionStyle(this.id + 'li');" onclick="changeSelectionStyle(this.id + 'li'); checkFatherSelection(this.id);"> <a href="#" onclick="document.getElementById('selectedAuthorities-4_1').click(); return false;"> Agregar comentario <samp><b></b>Permite agregar comentario en el detalle.</samp> </a> </li> Well what I cant get work is when the checkbox is selected, on load, the JS should check it, and assign class="yes" to the li, here: <li id="selectedAuthorities-4_1li" class=""> What should I add to my original JS function to make that possible. Note that li ids are not static, they are dynamic, the html li id is generated.

    Read the article

  • How can I read the value of a radio button in JavaScript?

    - by Corey
    <html> <head> <title>Tip Calculator</title> <script type="text/javascript"><!-- function calculateBill(){ var check = document.getElementById("check").value; /* I try to get the value selected */ var tipPercent = document.getElementById("tipPercent").value; /* But it always returns the value 15 */ var tip = check * (tipPercent / 100) var bill = 1 * check + tip; document.getElementById('bill').innerHTML = bill; } --></script> </head> <body> <h1 style="text-align:center">Tip Calculator</h1> <form id="f1" name="f1"> Average Service: 15% <input type="radio" id="tipPercent" name="tipPercent" value="15" /> <br /> Excellent Service: 20% <input type="radio" id="tipPercent" name="tipPercent" value="20" /> <br /><br /> <label>Check Amount</label> <input type="text" id="check" size="10" /> <input type="button" onclick="calculateBill()" value="Calculate" /> </form> <br /> Total Bill: <p id="bill"></p> </body> </html> I try to get the value selected with document.getElementById("tipPercent").value, but it always returns the value 15.

    Read the article

  • Javascript AJAX function not working properly

    - by Or W
    I have a function that sends a GET request to a php script and checks if the script returned any output. It works great, but when I try to add another function that checks for something similar, both of them fail. What am I missing? function checkUsername(usr,n) { var user = usr.val(), xmlhttp; //var str = document.getElementById('email').value; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { //document.getElementById("txtHint").innerHTML=xmlhttp.responseText; if (xmlhttp.responseText != "") { usr.addClass( "ui-state-error" ); updateTips( n ); return false; } else { return true; } } } xmlhttp.open("GET","ajaxValidate.php?type=user&q="+user,true); xmlhttp.send(); } The above works perfectly, when adding this function, none of them work: function checkEmail(em,n) { var email = em.val(), xmlhttp; //var str = document.getElementById('email').value; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { //document.getElementById("txtHint").innerHTML=xmlhttp.responseText; if (xmlhttp.responseText != "") { em.addClass( "ui-state-error" ); updateTips( n ); return false; } else { return true; } } } xmlhttp.open("GET","ajaxValidate.php?type=email&q="+email,true); xmlhttp.send(); }

    Read the article

  • JAVASCRIPT - What am I doing incorrectly?

    - by DarkLightA
    LIVE CODE: http://jsfiddle.net/vy4nY/ I'm following this challenge, but I'm having some issues. I'm trying to make the Email Address box only appear when the checkbox is clicked on. What have I done incorrectly? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <title>JavaScript Challenges</title> <style type="text/css"> #emailpara {visibility:hidden;} </style> </head> <body> <form action=""> <fieldset> <legend>Email subscriptions</legend> <p id="subscribepara"> <label> <input type="checkbox" name="subscribe" id="subscribe"> Yes! I would like to receive the occasional newsletter via email. </label> </p> <p id="emailpara"> <label> Email Address: <input type="text" name="email" id="email"> </label> </p> </fieldset> </form> <script type="text/javascript"> document.getElementById('subscribe').onclick = (document.getElementById('subscribe').checked ? (document.getElementById('emailpara').style.visibility = 'visible') : (document.getElementById('emailpara').style.visibility = 'hidden')); </script> </body> </html>

    Read the article

  • How to add on key down and on key up event in java script

    - by Ramesh
    Hello , I am creating an live search for my blog..i got this from w3 schools and i need to add on keyboard up,down mouse up and down event ... <html> <head> <script type="text/javascript"> function showResult(str) { if (str.length==0) { document.getElementById("livesearch").innerHTML=""; document.getElementById("livesearch").style.border="0px"; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("livesearch").innerHTML=xmlhttp.responseText; document.getElementById("livesearch").style.border="1px solid #A5ACB2"; } } xmlhttp.open("GET","livesearch.php?q="+str,true); xmlhttp.send(); } </script> </head> <body> <form> <input type="text" size="30" onkeyup="showResult(this.value)" /> <div id="livesearch"></div> </form> </body> </html>

    Read the article

  • How to use WebSockets refresh multi-window for play framework 1.2.7

    - by user2468652
    My code can work.But only refresh a page of one window. If I open window1 and window2 , both open websocket connect. I keyin word "test123" in window1, click sendbutton. Only refresh window1. How to refresh window1 and window2 ? Client <script> window.onload = function() { document.getElementById('sendbutton').addEventListener('click', sendMessage,false); document.getElementById('connectbutton').addEventListener('click', connect, false); } function writeStatus(message) { var html = document.createElement("div"); html.setAttribute('class', 'message'); html.innerHTML = message; document.getElementById("status").appendChild(html); } function connect() { ws = new WebSocket("ws://localhost:9000/ws?name=test"); ws.onopen = function(evt) { writeStatus("connected"); } ws.onmessage = function(evt) { writeStatus("response: " + evt.data); } } function sendMessage() { ws.send(document.getElementById('messagefield').value); } </script> </head> <body> <button id="connectbutton">Connect</button> <input type="text" id="messagefield"/> <button id="sendbutton">Send</button> <div id="status"></div> </body> Play Framework WebSocketController public class WebSocket extends WebSocketController { public static void test(String name) { while(inbound.isOpen()) { WebSocketEvent evt = await(inbound.nextEvent()); if(evt instanceof WebSocketFrame) { WebSocketFrame frame = (WebSocketFrame)evt; System.out.println("received: " + frame.getTextData()); if(!frame.isBinary()) { if(frame.getTextData().equals("quit")) { outbound.send("Bye!"); disconnect(); } else { outbound.send("Echo: %s", frame.getTextData()); } } } } } }

    Read the article

  • How to use javascript to include struts html tag?

    - by Dj
    I have a check box and a text box. I have used struts tags and Now i need to validate that if the check box is checked, i should gray out (disable) the text box. If it is unchecked the text box shold take phone numbers. I did lik this, i called a java script on click of check box and did a innerHtml based on wheather checkbox ix checked or not. var status_check=document.getElementById("line1Checked").checked; if(status_check==true){ text=""; } else{ text=""; } alert(text); document.getElementById("line1").innerHTML=text; this works but if i use, var status_check=document.getElementById("line1Checked").checked; if(status_check==true){ "; } else{ "; } alert(text); document.getElementById("line1").innerHTML=text; It doesn work. All i know is struts tags execute at server. is there any possiblity to achieve this? Please help me.

    Read the article

  • Javascript not working in firefox

    - by Samuel Meddows
    Hi guys, I have a PHP form validation function that I developed in chrome and now will not work in firefox or Opera. The function checks to see if a section of the form is blank and shows and error message. If there is no error then then the form submits through document.events.submit(); CODE: function submit_events() { //Check to see if a number is entered if the corosponding textbox is checked if (document.events.dj_card.checked == true && dj_amount.value==""){ //Error Control Method //alert ('You didn\'t enetr an Amount for DJ\'s Card!'); var txt=document.getElementById("error") txt.innerHTML="<p><font color=\"#FF0000\"> You didn\'t enetr an Amount for DJ\'s Card!</font></p>"; window.document.getElementById("dj_card_label").style.color = '#FF0000'; //Reset window.document.getElementById("company_amount_label").style.color = '#000000'; window.document.getElementById("own_amount_label").style.color = '#000000'; }else{ document.events.submit(); } The document.events.submit();does work across all my browsers however the check statements do not. If the box is not ticked the form submits. If the box is ticked it does not matter whether there is data in the dj_amount.value or not. The form will not submit and no error messages are displayed. Thanks guys.

    Read the article

  • Javascript: Change li class if checkbox is selected (on load)

    - by BoDiE2003
    I have this code on javascript side: function changeSelectionStyle(id) { if(document.getElementById(id).className != 'yes'){ document.getElementById(id).className = 'yes'; } else{document.getElementById(id).className = '';} } And this on html: <ul> <li id="selectedAuthorities-4_1li" class=""> <input type="checkbox" id="selectedAuthorities-4_1" name="selectedAuthorities" value="ROLE_ADD_COMMENT_TO_CV" checked="checked" onload="changeSelectionStyle(this.id + 'li');" onclick="changeSelectionStyle(this.id + 'li'); checkFatherSelection(this.id);"> <a href="#" onclick="document.getElementById('selectedAuthorities-4_1').click(); return false;"> Agregar comentario <samp><b></b>Permite agregar comentario en el detalle.</samp> </a> </li> </ul> Well what I cant get work is when the checkbox is selected, on load, the JS should check it, and assign class="yes" to the li, here: <li id="selectedAuthorities-4_1li" class=""> Any suggestions? Thank you

    Read the article

  • jQuery Validate on form submitted by JavaScript

    - by Daniel
    My form is submitted by a link using JavaScript, but I am also trying to validate the from justing jQuery validate. The validation doesn't work when submitted by the link, but it does if I change the link to a submit button. What am I doing wrong? My form: <form id="findmatch" method="post" action="search"> <div> <label class="formlabel">Match Type <input type="text" name="matchtype" id="matchtype" class="forminput" /> </label> <label class="formlabel">Location (postcode) <input type="text" name="location" id="location" class="forminput" /> </label> <label class="formlabel">Radius (miles) <input type="text" name="Radius" id="Radius" class="forminput" /> </label> <label class="formlabel">Keywords <input type="text" onblur="javascript:usePointFromPostcode(document.getElementById('location').value, showCompleteLatLng)" onchange="javascript:usePointFromPostcode(document.getElementById('location').value, showCompleteLatLng)" name="keywords" id="keywords" class="forminput" /> </label> <input id="lat" class="hidden" name="lat" type="text" value="" /> <input id="lon" class="hidden" name="lon" type="text" value="" /> <a href="javascript:document.getElementById('findmatch').submit();" onmouseover="javascript:usePointFromPostcode(document.getElementById('location').value, showCompleteLatLng)" class="submit">Search</a> </div> </form> And my jQuery is <script type="text/javascript"> $(document).ready(function () { $("#findmatch").validate({ rules: { location: "required", Radius: { required: true, digits: true }, keywords: "required" }, messages: { location: "Please enter your postcode", Radius: { required: "Please enter a radius", digits: "Please only enter numbers" }, keywords: "Please enter the keywords you wish to search for" } }); }); </script>

    Read the article

  • Ajax div can't access address bar variable

    - by Elaine Adams
    Can someone please advise me on how my Ajax div can get an address bar variable. The usual way just doesn't work. My address bar currently looks like this: http://localhost/social3/browse/?locationName=Cambridge Usually, I would use a little php and do this: $searchResult = $_POST['locationName']; echo $searchResult; But because I'm in an Ajax div, I can't seem to get to the variable. Do I need to add some JavaScript wizardry to my Ajax coding? (I have little knowledge of this) My Ajax: <script> window.onload = function () { var everyone = document.getElementById('everyone'), searching = document.getElementById('searching'), searchingSubmit = document.getElementById('searchingSubmit'); everyone.onclick = function() { loadXMLDoc('indexEveryone'); everyone.className = 'filterOptionActive'; searching.className = 'filterOption'; } searching.onclick = function() { loadXMLDoc('indexSearching'); searching.className = 'filterOptionActive'; everyone.className = 'filterOption'; } searchingSubmit.onclick = function() { loadXMLDoc('indexSearchingSubmit'); } function loadXMLDoc(pageName) { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("leftCont").innerHTML=xmlhttp.responseText; } } function get_query(){ var url = location.href; var qs = url.substring(url.indexOf('?') + 1).split('&'); for(var i = 0, result = {}; i < qs.length; i++){ qs[i] = qs[i].split('='); result[qs[i][0]] = decodeURIComponent(qs[i][1]); } return result; } xmlhttp.open("GET","../browse/" + pageName + ".php?user=" + get_query()['user'],true); xmlhttp.send(); } } </script> <!-- ends ajax script -->

    Read the article

< Previous Page | 5 6 7 8 9 10 11 12 13 14 15 16  | Next Page >