File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to retrieve string representation of <INPUT> value?

 
Daniel Martin
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As the topic describes, how is it done?

I thought that by default, the value of a form input field is a string. I need to retrieve substrings of the input string but I have not been able to achieve that.

Any ideas?

For instance, say I have the following INPUT tag.

If I copy and paste the code below from a YouTube page into the INPUT tag, I would like to parse it later on with Javascript. I assume that it would be stored as a string.

How do I do this?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can access the value of the input element by element.value.
 
Daniel Martin
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I know that. I am using that to pass the value into a Javascript function. In the function is where I am having problems.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Form submission has nothing to do with JavaScript. I assume you are trying to do something with the value before the form is submitted?

If so, you'll need to be more specific about whatever problems you are having.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Martin wrote:Yes, I know that. I am using that to pass the value into a Javascript function. In the function is where I am having problems.
Please elaborate about those problems then. As far now it's all too vague. What are the functional requirements? What do you have? What happens now? What happens not? What do you want to end up?
 
Daniel Martin
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I don't know of a good way of explaining it but I'll try to expand on what I said on the first post. I have an open source HTML editor that I got from http://www.openwebware.com/. I am trying to add further functionality to it, like the ability to add YouTube videos, Java Applets, templates, and so on.

I already created the YouTube button. When pressed, a popup page shows up by the following code:


The WYSIWYG.insertYouTube function is as follows:

 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well you probably should be using a normal button and not a submit button.

When you debug your code is alert(code.substr(0,12)) giving you anything?

Eric
 
Daniel Martin
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
^^ Nope, nada, just an empty alert popup.

I am using the submit button because all other existing popup menus follow this scheme and they work. So I tried following the same.
 
Daniel Martin
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Martin wrote:^^ Nope, nada, just an empty alert popup.


I'm sorry, the <OBJECT> code copied from YouTube does show up in the alert message. I initially did it wrong when you asked.

So what does this mean???
 
Daniel Martin
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alright, I finally got it!

Basically, all I did was use the toString function call on the code parameter argument of my insertYouTube function. From there, I was able to parse the string using substr , indexOf, and so on.

So to some it up, I was able to achieve my goal of inserting a YouTube video into my page editor.


Thanks for all your help folks.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic