Updating textarea from a popup


It's been a while since I've been here, and sadly my return is for another question.

Basically, what I want to do is update a textarea in the parent window with data from the child (pop-up) window.

There's an add image button on the main parent window that, when clicked, opens a pop-up window to upload an image and select its alignment (left, center and right). When the image is uploaded successfully, I want to send an img tag with the path to the newly uploaded file (and the alignment in the style attribute) to a textarea in the parent window.

The original plan was to upload the file in the parent window itself, but any Ajax file uploading tutorial that I read didn't work in my code, though I tested it outside of my code and it worked fine (didn't refresh the page). It doesn't need to be on the parent page, I just thought it would be easier than doing it through a pop-up window, and I don't want to bother figuring out why it's not working with my code so I'm sticking with a pop-up.

Here is the textarea:


Here is my uploading page:
function uploadEnd(success, filename, align) { if(success == 1) { switch(align) { case 1: image_tag = ""; break; case 2: image_tag = ""; break; case 3: image_tag = ""; break; } window.opener.getElementById('content').value += image_tag; } } uploadEnd(, "/", ); Image:
Choose image alignment: Left Center Right


Uploading works fine. Updating the textarea does not. I know I'm probably doing it wrong, which is why I've come here for help because I've been trying to get this to work for over a day now with no success.

Any help would be greatly appreciated as I'd like to get this site finished before the new year (though I doubt I will succeed).

I can try to provide more information if necessary.
Posted On: Wednesday 21st of November 2012 01:53:28 AM Total Views:  386
View Complete with Replies

RELATED TOPICS OF JavaScript PROGRAMMING LANGUAGE




rssdisplayer.js not updating, auto-refresh?

A noob needs some help. I'm using a combination of Yahoo Pipes and rssdisplayer.js to display some snippets from several RSS feeds on a new site I'm building. The trouble I'm having is that (i) the feeds don't update when I refresh the page, I think because a cached version of the page is being loaded, and (ii) I'd like to have the div containing the feeds auto-refresh at a given time interval. I've got a Twitter javascript working that does both these things, but can't work out how to get the rssdisplayer.js working this way. The rssdisplayer code is: Code: google.load("feeds", "1") //Load Google Ajax Feed API (version 1) function rssdisplayer(divid, url, feedlimit, showoptions){ this.showoptions=showoptions || "" //get string of options to show ("date" and/or "description") var feedpointer=new google.feeds.Feed(url) //create new instance of Google Ajax Feed API feedpointer.setNumEntries(feedlimit) //set number of items to display document.write('Loading feed...') this.feedcontainer=document.getElementById(divid) var displayer=this feedpointer.load(function(r){displayer.formatoutput(r)}) //call Feed.load() to retrieve and output RSS feed } rssdisplayer.prototype.formatdate=function(datestr){ var itemdate=new Date(datestr) return ""+itemdate.toLocaleString()+"" } rssdisplayer.prototype.formatoutput=function(result){ if (!result.error){ //if RSS feed successfully fetched var thefeeds=result.feed.entries //get all feed entries as a JSON array var rssoutput="" for (var i=0; i
VIEWS ON THIS POST

158

Posted on:

Wednesday 17th October 2012
View Replies!

Cookie reading/incrementing/updating

Novice Javasript query. My requirement: Each time a visitor arrives at a specific webpage i want the main image on the page to be different, or more specifically, one of 6 images which will be shown in rotation. Solution: Set a cookie. Each time the visitor access the page read the cookie and display the corresponding image. Then increment the value and rewrite the cookie, so that next time they'll see the next image in sequence. NB: if the cookie does not exist (first timer) or is at 6, then the value is set to zero (and then incremented). Problem: Can't get my coding to work. Specifically it just doesn't do anything - no error message, no cookie written. I'm a very novice scripter, as in I've cobbled the coding together from bits off the net that i think i've managed to grasp some kind of an understanding of. Very suck it and see - so far lots of sucking and no seeing! Anyway here's my code - if someone could cast a beady eye it would be much appreciated. Hopefully I'm not a million miles out !!! Code: /**/
VIEWS ON THIS POST

150

Posted on:

Wednesday 17th October 2012
View Replies!

updating href of link with shadowbox & flash

, I have a site that uses JS to swap images e.g. user clicks on a thumbnail and then the main image changes to show the thumb they've clicked on. So now I'd like that main image to link somewhere, and to change where it links to when the thumb is clicked on also. The link updates ok using my JS, but the shadowbox always loads the flash using the same image variable, not the new one my JS is specifying. Here's my code: Image in Source Code: Code: Thumb in Source code: Code: Javascript to change the main image: Code: function selectPicture(uniqueid,imgno) { var filenamepic = '../thumbnails/phpThumb.phph=333&w=284&src=../uploads/' + uniqueid + '_original_' + imgno + '.jpg'; var linkurl = 'http://www.mysite.co.uk/zoom/zoom.swfimage=../thumbnails/phpThumb.phph=333&w=284&src=../uploads/' + uniqueid + '_original_' + imgno + '.jpg'; document.getElementById('myAnchor').href=linkurl; document.mainimage.src=filenamepic; } So the document.mainimage.src bit works, as it updates the main image, the link is updated but the shawdowbox and Flash is always showing the image it is first sent when the page is loaded. Does anyone have any ideas on how to get round this
VIEWS ON THIS POST

212

Posted on:

Saturday 20th October 2012
View Replies!

Button not updating after click...with javascript/ajax

I have these buttons that I need to have switch accounts on and off. They work, but for some reason the words on the buttons are not changing from Activate to Deactivate... It seems as though the button is not updating itself after success of the function. First post on here so I apologize if I am doing this wrong. Problem code in jsbin--> http://jsbin.com/okifa3/ Code: $(function() { var activateOwner = function(u) { var dataString = 'oid=' + u + "&a=1"; $.ajax({ type: "GET", url: "{/literal}{$site_root_path}{literal}account/toggle-owneractive.php", data: dataString, success: function() { $('#spanowneractivation' + u).css('display', 'none'); $('#message1' + u).html("Activated!").hide().fadeIn(1500, function() { $('#message1' + u); }); $('#spanownernamelink' + u).css('display', 'inline'); $('#' + u).val('Deactivate'); $('#spanownernametext' + u).css('display', 'none'); $('#' + u).removeClass('btnActivate'); $('#' + u).addClass('btnDectivate'); setTimeout(function() { $('#message1' + u).css('display', 'none'); $('#spanowneractivation' + u).hide().fadeIn(1500); }, 2000 ); } }); return false; }; var deactivateOwner = function(u) { var dataString = 'oid=' + u + "&a=0"; $.ajax({ type: "GET", url: "{/literal}{$site_root_path}{literal}account/toggle-owneractive.php", data: dataString, success: function() { $('#spanowneractivation' + u).css('display', 'none'); $('#message1' + u).html("Deactivated!").hide().fadeIn(1500, function() { $('#message1' + u); }); $('#spanownernamelink' + u).css('display', 'none'); $('#spanownernametext' + u).css('display', 'inline'); $('#' + u).val = 'Activate'; $('#' + u).removeClass('btnDeactivate'); $('#' + u).addClass('btnActivate'); setTimeout(function() { $('#message1' + u).css('display', 'none'); $('#spanowneractivation' + u).hide().fadeIn(1500); }, 2000 ); } }); return false; }; $(".toggleOwnerButton").click(function() { if($(this).val() == 'Activate') { activateOwner($(this).attr("id")); } else { deactivateOwner($(this).attr("id")); } }); });
VIEWS ON THIS POST

148

Posted on:

Saturday 20th October 2012
View Replies!

Self-updating content problem

Resolved
VIEWS ON THIS POST

173

Posted on:

Saturday 20th October 2012
View Replies!

problame with updating data automatic from database...please help

hello , I made a simple messageing script with php and when i send message somebody he need to refresh his page for biew new message... but i want that will be automatically show to him after i send message, thats mean when i send a message to anybody it will be shown to him without refresh like facebook chatting so i need help, i need that script which will be help me to retrive data from database without refresh ... if u know then please help me Thank You in advance
VIEWS ON THIS POST

216

Posted on:

Thursday 25th October 2012
View Replies!

updating css properties using JavaScript (not working well in IE9)

, Can anyone help me find a solution for this I'm building a website for my mom's store. -> http://ndias.info/cc/ And I'm having a hard time with the navigation menu. I made some "fadeIn" "fadeOut" effects that run well in Chrome 12, FireFox 5, but not in IE9! I think the problem might the way css properties are being updated I am trying to update this, #thumb_00 { opacity: 0.3; } #thumb_01 { opacity: 0.3; } #thumb_02 { opacity: 0.3; } #thumb_03 { opacity: 0.3; } #thumb_04 { opacity: 0.3; } Using this, function mouseOver(thumb){ var thumbCounter = 4; var thumbIntervalId = setInterval( function thumbEffect(){ if(thumbCounter3) { document.getElementById("thumb_"+thumb).style.opacity = "0." + thumbCounter; thumbCounter--; } if (thumCounter == 3) { clearInterval(thumbOutIntervalId); } },20); } MouseOver and MouseOut fade effects are not working well in IE9... Which is odd, because I'm using exactly the same technique for the fadeIn effect onclick, and it works like a charm :\
VIEWS ON THIS POST

143

Posted on:

Monday 12th November 2012
View Replies!

textarea problem in firefox

When I in FF send an updated textarea text for database update I do not get the current value, but the old value. I use jquery, and as far I can tell there is nothing strange in the code, thd DOM is loaded etc. When I do the same in IE if works fine. Is this a known issue Hopefully I made myself understood, if not please take inte consideration I'm Swedish ;)
VIEWS ON THIS POST

180

Posted on:

Friday 16th November 2012
View Replies!

assign content of textarea to a div as in twitter

i want to assign content of textarea to a div .. like in twitter when you type something and press "Tweet" a div is created and has the content of textarea.. how can i implement it , i know something about getElementById() but not sure how it can help me here
VIEWS ON THIS POST

175

Posted on:

Friday 16th November 2012
View Replies!

Do you know what error? how include rich textarea?

Do you know what error how include rich text-area in jQuery and http://tinymce.moxiecode.com/ see attach... get ONLY text-area non rich text-area. $(document).ready(function(){ $('textarea.rte').each(function(){ TINYMCE.replace(this.name); }); }); Page Text
VIEWS ON THIS POST

266

Posted on:

Friday 16th November 2012
View Replies!

jquery - check and replace href of textarea

Hi all, I am at a stand still with trying to figure this out. I have a textarea, i would like to check for links entered by users and replace/remove the anchor attribute from the string. ie. change website to website its more so to validate ( i have a php side working to validate for links but am trying to get jquery to just remove it and maybe say a warning. function textarea(){ var message = $("#text").val(); // How would you check the text here and remove all links typed in by the user }); if someone might know where to start with this it would be much appreciated
VIEWS ON THIS POST

233

Posted on:

Friday 16th November 2012
View Replies!

Online ajax updating

, in twitter and facebook when some of your friends/follows makes new post, your page gets updated via ajax. any ideas how it is implemented i need the best concept/idea, not the code :] thnx in advance
VIEWS ON THIS POST

196

Posted on:

Friday 16th November 2012
View Replies!

Needs help with updating db with jquery ajax

I am working on submitting a form with various info to update on db using jquery, ajax. The db is updating perfectly when I disable JS on firefox. When enabled, a few fields (adID, userID, comments) are not updating on the db. The field userID updated as zero, but the other two are blank. Structure of table : Field-Type adID-varchar(250) userID-int(11) ContactDate-date IP-varchar(250) ModeOfContact-varchar(250) comments-text Please help me. jquery code : $("#Econtactadvertiserpanelsubmit").click(function(){ $("#Econtactadvertiserpanel").append("Please wait.."); var comments = $("#emailmsg").val(); var adID = $("#adID").val(); var userID = $("#userID").val(); var ContactDate = $("#ContactDate").val(); var ip = $("#ip").val(); var ModeOfContact = $("#ModeOfContact").val(); //console.log(emailmsg,con_name); $.ajax({ type: "POST", url: "sendmail/selemail.php", data: 'adid=' + adID + '&userid=' + userID + '&ContactDate=' + ContactDate + '&ip=' + ip + '&ModeOfContact=' + ModeOfContact + '&comments=' + comments, success: function(result){ console.log(result); } }) return false; }); HTML form : Your Name Your Message
VIEWS ON THIS POST

221

Posted on:

Friday 16th November 2012
View Replies!

problem with tag inside ?

I have written some code for template generator but I am having issue getting the formatting when it is generated in the . I want to have it to look like Service Affected: {then populated text} Service Status: {again populated text} Current/Next Actions: {populated text} it ends up printing out the Service Impacted: dataService Status : lost comms here is the code I have written. function generate() { var sms = '' var impact = document.sms.impacted.value; var status = document.sms.status.value; var action = document.sms.action.value; var BR = '' sms = sms + ''; sms = sms + 'Service Impacted: '+ impact + ''; sms = sms + 'Service Status : '+ status + ''; sms = sms + 'Next Action : '+ action +''; sms = sms + ''; document.getElementById('sms').innerHTML=sms; //document.getElementById('blank').innerHTML=''; }   The Fault logging assistant SMS Template Genterator Service Impacted: Service Status: Next Action:
VIEWS ON THIS POST

193

Posted on:

Friday 16th November 2012
View Replies!

Get value from with javascript?

I would like to write a page which accepts Value of textbox / input-field using javascript. As you get values from this: var cheese=1 document.write(cheese) Maybe the value cheese could be taken from text which the user has to enter....how
VIEWS ON THIS POST

135

Posted on:

Monday 19th November 2012
View Replies!

How to get a value from textarea in javascript?

why this code shows tags ---------------------------- > My Editor
VIEWS ON THIS POST

142

Posted on:

Monday 19th November 2012
View Replies!

Dynamic input to to textarea

I am trying to code a webpage that does the following: Listens for user key presses in an input box and dynamically writes them below the input box in a textarea.
VIEWS ON THIS POST

142

Posted on:

Monday 19th November 2012
View Replies!

Ajax replacement for auto-updating iFrame

I'm looking to replace an auto-updating iFrame with some cooler, and more accurate ajax code. And first off I'll say that I believe ajax is the right way to approach this, but I'm open to suggestions, too. I'm not really much of a javascript/ajax programmer, hence I'm hoping for a little guidance here. Being an MCSD, I do understand and can read code and pseudo-code. The website where this is needed is an internet radio station. The auto-updating iFrame shows what song is currently playing. It's best if you just see it, so please feel free to visit Girls Rock Radio and notice the "Now Playing" section of each page at the site on the right side of the page, below the title graphic and nav bar. The iFrame displays a page that auto-refreshes every 90 seconds. That works out pretty well, and it seems to update frequently enough to make it seem that it's keeping pretty constant track with the actual song change, even though it's really not. Behind the scenes, the radio station automation software is updating a file on the web server precisely when the song changes. I can control what information goes into that file, like artist, song title, album, year, genre, filespec to the album art, etc... Pretty much anything that's in the database about that song. What I may NOT be able to enter into that file is something outside of the database - the time the song just started playing, for instance - which would be valuable to know in this situation. But I do have the date/time the file was updated from the servers file system, so I'm no worse for the wear, I guess. Song length is in the database, so some math based on file date/time and song length should be able to produce the next update file read. Can anyone help me with some ideas on how to handle an auto-updating ajax replacement for the existing auto-updating iFrame
VIEWS ON THIS POST

186

Posted on:

Monday 19th November 2012
View Replies!

unable to make text in textarea bold on pressing a button

function up() { var obj=document.survey.results.value document.survey.results.value=obj.bold } This post has been edited by Dormilich: 14 October 2012 - 09:13 AM Reason for edit:: please use [CODE] [/CODE] tags when posting code
VIEWS ON THIS POST

148

Posted on:

Monday 19th November 2012
View Replies!

adjusting textarea cols by div width

HTML part: javascript part: function contact() { document.getElementById('one').onclick=""; document.getElementById('two').onclick=""; document.getElementById('one').width="25%"; document.getElementById('two').width="75%"; document.getElementById('one').style.cursor=""; document.getElementById('one').vAlign = "top"; document.getElementById('two').vAlign = "top"; document.getElementById('one').style.backgroundImage = null; document.getElementById('two').style.backgroundImage = null; document.getElementById('one').style.lineHeight="150%"; document.getElementById('two').style.lineHeight="50%"; document.getElementById('two').align = "left"; var GPwidth = document.getElementById('bodyC').style.width; GPwidth = GPwidth * 20; document.getElementById('one').innerHTML = "First Name: Last Name: Email: Subject: "; document.getElementById('two').innerHTML = "Send"; document.getElementById('Tarea').overflow="auto"; document.getElementById('Tarea').cols = GPwidth; } css part: #bodyC { position:fixed; top:40%; left:-1; width:100%; height:60%; } .bodyCC { background-image: url(http://oi45.tinypic.com/m7gqcx.jpg); position: fixed; background-repeat: no-repeat; background-size: 100% 50%; } I only copied the parts that matter. bodyC is sort of the background table, and i'm trying to make the cols in the textarea to be relative to its' width. i've tried var GPwidth = document.getElementById('bodyC').style.width; GPwidth = GPwidth * 20; document.getElementById('Tarea').cols = GPwidth; (which you can see in the javascript part) but each time it gives me 0 cols. i've also tried changing the "width=100%" in the CSS to "width=800" but there still were 0 cols. can anyone help
VIEWS ON THIS POST

154

Posted on:

Monday 19th November 2012
View Replies!