Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Jquery: How Do I set a value for an input field that is wrapped in td and span tag

Posted on 2010-08-18
6
Medium Priority
?
550 Views
Last Modified: 2013-11-11
Hi,

I want to set a value for any input field that is wrapped in a <td class="orderQty selected">

form:
<td><span><input/></span><span><Input THIS INPUT VALUE/></span></td>

the input field's value that I want to change is title="Order Number" with the value of the variable modTest
$('#Target').focus(function(event) {
  
 var mod = event.timeStamp;
 var modTest = mod / 1000;
  

}); 
});

-------------------------------------------------------------

<TD class="orderQty selected" sizcache="7" sizset="43"><SPAN dir=none sizcache="6" sizset="43"><INPUT style="IME-MODE: inactive" id=ctl00_m_g_7279058e_e51a_4bdc_bae0_cf09ae6c9811_ff10_1_ctl00_ctl00_TextField class=ms-input title=OrderQty value=3 size=11 name=ctl00$m$g_7279058e_e51a_4bdc_bae0_cf09ae6c9811$ff10_1$ctl00$ctl00$TextField jQuery1282145205046="1"><BR></SPAN><SPAN dir=none sizcache="6" sizset="44"><INPUT id=ctl00_m_g_7279058e_e51a_4bdc_bae0_cf09ae6c9811_ff12_1_ctl00_ctl00_TextField class=ms-long title="Order Number" value=0 maxLength=255 name=ctl00$m$g_7279058e_e51a_4bdc_bae0_cf09ae6c9811$ff12_1$ctl00$ctl00$TextField jQuery1282145205046="2"><BR></SPAN></TD>

Open in new window

0
Comment
Question by:Solutionabc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 15

Expert Comment

by:SRigney
ID: 33466495
$("input [title='Order Number'").val(modTest);
0
 

Author Comment

by:Solutionabc
ID: 33466582
is that   [   suppose to be in there?
0
 

Author Comment

by:Solutionabc
ID: 33466652
I thought that I would have to search for a td with the class="orderQty" then get it's child that has the title="Order Number" ?

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 15

Expert Comment

by:SRigney
ID: 33467250
yeah the [ is supposed to be there it's the attribute matcher in jQuery
http://api.jquery.com/attribute-equals-selector/
0
 

Author Comment

by:Solutionabc
ID: 33467530
ok,

when I put that code in and do an alert with a value in the input box I get "Undefined"

for some reason it is not working.
$(document).ready(function(){
     
  $(".orderQty span INPUT").change(function(){
  
         if($(this).val() > 0 ) {
        
          $(this).parents("td").addClass("selected");
           var title1 = $("input [title = 'Order Number']").val();
            alert(title1);
        } else {
            $(this).parents("td").removeClass("selected");
        }
});

Open in new window

0
 
LVL 15

Accepted Solution

by:
SRigney earned 2000 total points
ID: 33467841
Sorry, slight problem with the matcher

This one gave me the value 0
alert($("[title=Order Number]").val());
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

670 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