• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

How to retrieve string representation of <INPUT> value?

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can access the value of the input element by element.value.
 
Daniel Martin
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67537
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
I am mighty! And this is a mighty small ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic