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


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

<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

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

$("input [title='Order Number'").val(modTest);
SolutionabcAuthor Commented:
is that   [   suppose to be in there?
SolutionabcAuthor Commented:
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" ?

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics ā€“ known as key performance indicators (KPIs) ā€“ for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

yeah the [ is supposed to be there it's the attribute matcher in jQuery
SolutionabcAuthor Commented:

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.
  $(".orderQty span INPUT").change(function(){
         if($(this).val() > 0 ) {
           var title1 = $("input [title = 'Order Number']").val();
        } else {

Open in new window

Sorry, slight problem with the matcher

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.