Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Inserting text into a form field from a popup window
Old 01-23-2009, 01:13 AM Inserting text into a form field from a popup window
Average Talker

Posts: 16
Trades: 0
I've gotten a lit ambitious and want to break free from WordPress with my site, so I've spent the last few days with XAMPP trying to get my post form functioning. For the most part I've been very successful, as I've had quite a bit of experience and training with php and mySQL databases. Where I'm lacking in skill is the Javascript department.

I have a page for uploading images that opens in a JS popup window, and once the images are uploaded you can click a link to insert it into a form field on the main page. My code for that looks like this:

Code:
<a href="javascript:void(window.opener.document.FORM.FIELD.value
= 'FILENAME' )">Insert into post</a>
The problem is that, currently, clicking the link will replace anything already in the form field. What I need it to do is insert the text at the cursor position without replacing anything.

I've scoured Google for a solution, but nothing I've found pertains to inserting the text from a popup window.
Kent O'Matic is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-23-2009, 01:27 AM Re: Inserting text into a form field from a popup window
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
JAMISONTUNES
Posts: 2,898
Name: Keith Marshall
Location: Connecticut
Trades: 0
I don't think there is a way to determine the exact location of the cursor in the text field, but you can append new data to it:

Code:
<a href="#" onclick="window.opener.document.FORM.FIELD.value=window.opener.document.FORM.FIELD.value+'FILENAME';">Insert into post</a>
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 01-23-2009, 01:37 AM Re: Inserting text into a form field from a popup window
Average Talker

Posts: 16
Trades: 0
Awesome! That'll work for now. Thanks for the speedy reply.
Kent O'Matic is offline
Reply With Quote
View Public Profile
 
Old 01-23-2009, 04:47 AM Re: Inserting text into a form field from a popup window
Insensus's Avatar
Ultra Talker

Posts: 487
Name: Mark Stegeman
Location: Netherlands, Europe
Trades: 0
You can get the cursor position in the field, but I've never understood how that works.
I'll search around for you.

This looks promising:
http://alexking.org/blog/2003/06/02/...ing-javascript
__________________
<?php ($helpfull>0)?$talkupation++ : '';?>

Last edited by Insensus; 01-23-2009 at 04:48 AM..
Insensus is offline
Reply With Quote
View Public Profile
 
Old 01-23-2009, 06:11 AM Re: Inserting text into a form field from a popup window
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Here's one we prepared earlier.

http://www.webmaster-talk.com/javasc...tml#post772383
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Inserting text into a form field from a popup window
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.27284 seconds with 12 queries