Solved

get text from inpu

Posted on 2014-11-20
9
62 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
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…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

726 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