473,378 Members | 1,470 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to make the value of a text box the same as a variable?

Hi, I'm trying to learn Javascript. I've been learning for a long time and decided maybe I'll do my first useful project.

This code is a bookmarklet for quickly uploading to tinypaste.com. It is meant to be used in a browser without any HTML. It ('s purpose is) gets your selection into a variable (x) then goes to tinypaste.com and paste the text in the main text box. (id: 'input_text')
It would be nice to give a prompt during the process for the title as well ('paste_title') and to automatically 'click' send, then get the url of the paste and alert it to you.

Expand|Select|Wrap|Line Numbers
  1. javascript:
  2.  
  3. x = "" + (window.getSelection ? window.getSelection() : document.getSelection ? document.getSelection() : document.selection.createRange().text); 
  4.  
  5. window.location= "http://tinypaste.com/";
  6.  
  7. alert (x);
  8.  
  9. document.getElementsById("input_text").value= (x);
  10.  
At the moment, the code gets the text properly, goes to tinypaste, but doesn't change the value of input_text.


When I do start at tinypaste, select the text, then use the bookmarklet, it changes the value fine, then as soon as that happens, it goes to tinypaste again.

Doesn't this mean that its changing the value BEFORE going to tinypaste? I'm suspecting that is the problem and how do I fix this?

Any help would be appreciated. Thanks.
Sep 30 '10 #1
5 1270
acoder
16,027 Expert Mod 8TB
You can open a new window instead. Once the location changes, I don't think there's any way to get the rest to run
Oct 1 '10 #2
How do I do that...?
Won't the rest of the code then still run in the current webpage?
Oct 1 '10 #3
acoder
16,027 Expert Mod 8TB
I've not really played much with bookmarklets, so I'm not sure if it'd work, but you can keep a reference to the opened window and then set the value of the text box on the opened window.
Oct 1 '10 #4
Hmm... Ok how do you open a new window directly from javascript, if this is even possible?
(to my knowledge it isn't)
Oct 1 '10 #5
acoder
16,027 Expert Mod 8TB
With window.open(). See some examples of bookmarklets here (though, it mentions Opera, most should work in all browsers).

Edit: looking at your original URL, I noticed this page which should help solve your problem. I think you'll find that if you're on another domain, you'll have permissions issues, so the best way would be to adapt their own bookmarklet.
Oct 2 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Brian | last post by:
Ok, so i know the title is a little confusing but let me put it this way lets say i have an array of strings, and with each string inside the array, i want to make a new class problems: 1)...
3
by: Byron | last post by:
Hi, Javascript confuses me, so I usually limit myself to Dreamweaver's built-in scripts for stuff like imageswaps. But this time I'm trying to write something very simple myself. I do most of my...
0
by: clv | last post by:
Hello: I need to rescue the value of a variable type application from a file ".vb", when making "j = Application("test")" throws an error to me, if I the same make from a pagina aspx I do not...
8
by: hb | last post by:
Hi, I need to declare a variable who's value can be preserve through the same ASP.Net page. I tried the following code, only the static variable s2 keeps its value=22 after lnk1_Click followed...
1
by: Carlos | last post by:
Hi all, I am new to asp .net with vb, and just need to know how to make the value of a variable available to all the pages in the project. That is, I capture the value of a variable using...
10
by: Blaxer | last post by:
There is probably a really easy way to do this, so please forgive me but I would like to set the value of a variable from a variable, an example would be... function Calculate_Something(ByVal...
6
by: rdstevenson | last post by:
Hi, Something I've never come across before and has given me a headache. I have a txt file with content similar to below I want to read in each line do a split on the = and then create a...
5
by: maker.rain1 | last post by:
Hello All, I have come across a problem as explained below in a sample. Please help me if anyone has any ideas to solve this. I have a #define as defined below. #define MAX 200 int...
3
Atli
by: Atli | last post by:
Hi everybody. This is not so much a problem, since I have already managed to find a solution, but my solution requires the use of the eval() function, which I just hate to use. The problem is...
2
by: deepunarayan | last post by:
Hi, I have an ASP page with 3 frames on it. The let frame will have Index (in Tree Structure format) right one is the Content Frame shows the contents on the selected node. The bottom frame as...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.