Solved

get text from inpu

Posted on 2014-11-20
9
61 Views
Last Modified: 2014-12-08
Hi,

I am trying to get the text from an input of type text like so:
<input type="text" id="inpAvg" name="gasaverage" value="" style="width: 60%;" />

Open in new window

with this jQuery
var avg = $("#inpAvg").val();

Open in new window

but it returns an empty string no matter what I put in the input.

What is wrong?

Best regards
RTSol
0
Comment
Question by:RTSol
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40455329
http://jsfiddle.net/zrej6aj8/

<input type="text" id="inpAvg" name="gasaverage" value="IM NOT EMPTY" style="width: 60%;" />
0
 
LVL 2

Expert Comment

by:Elxn
ID: 40455361
You should remove the value="" part of the input HTML.
0
 

Author Comment

by:RTSol
ID: 40455510
It's very dtrange but nothing of the above works fro me. The input resides inside a view in a hybrid mobile app. I am going nuts. Any ideas?
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 2

Accepted Solution

by:
Elxn earned 250 total points
ID: 40455522
Are you sure you don't have another element with the same ID?  Sounds like you have quite a bit of code.
0
 

Author Comment

by:RTSol
ID: 40455558
It's a lot of code but the id is unique
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40455723
provide a link this website
0
 

Author Comment

by:RTSol
ID: 40455846
Well - it is a mobile app so I can't.
0
 
LVL 10

Assisted Solution

by:Hans Langer
Hans Langer earned 250 total points
ID: 40463094
obviously you are getting a different element.
- try using a different ID,
- try getting it by the name $("[name='gasaverage']").val()
- be sure that the "val()" and "$" function are not overwritted. Use document.getElementId('inpAvg').value
- are you using iframes? or frames?
0
 

Author Closing Comment

by:RTSol
ID: 40486499
Hi guys,

Sorry for the delay. It actually was a problem with multiple IDs. I was using requirejs and didn't realize that all the html was lodaed when the app was run. stupid of me - thanks.

Best regards
RTSol
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question