Solved

get text from inpu

Posted on 2014-11-20
9
57 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now