InvAutomation
asked on
how to get the value in a table to be in a field on a form with jquery
Hi.
I have a form that I'm that I'm trying to get dat into the fields from a table on the page. the info in the table changes when a dropdown is selected. I'm trying to retreive some of the data in the columns and place it in a form on the page with jquery. I'm having a bit of trouble. Can anyone help??
Below is the table that I'm trying to catch the data from....
I have a form that I'm that I'm trying to get dat into the fields from a table on the page. the info in the table changes when a dropdown is selected. I'm trying to retreive some of the data in the columns and place it in a form on the page with jquery. I'm having a bit of trouble. Can anyone help??
Below is the table that I'm trying to catch the data from....
<!--<table TOPLEVEL border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td valign="top">
<div >
<table>
<tr valign="top">
<th class="ms-vh" nowrap>app</th>
<th class="ms-vh" nowrap id="appData">business owner</th>
<th class="ms-vh" nowrap>Busness Owner2</th>
</tr>
<tr class="ms-alternating">
<td class="ms-vb">ab</td>
<td class="ms-vb">
<nobr>
<span>
<A HREF="">Business Owner Value</A>
</span>
</nobr>
</td>
<td class="ms-vb">
<nobr>
<span>
<A HREF="">Business Owner 2 Value</A>
</span>
</nobr>
</td>
</tr>
</table>
ASKER
Sorry about that!
I'm trying to get the values in these rows:
<td class="ms-vb">ab</td>
<td class="ms-vb">
<nobr>
<span>
<A HREF="">Business Owner Value</A>
</span>
</nobr>
</td>
<td class="ms-vb">
<nobr>
<span>
<A HREF="">Business Owner 2 Value</A>
</span>
</nobr>
</td>
Then I'm trying to put those values in
I'm trying to get the values in these rows:
<td class="ms-vb">ab</td>
<td class="ms-vb">
<nobr>
<span>
<A HREF="">Business Owner Value</A>
</span>
</nobr>
</td>
<td class="ms-vb">
<nobr>
<span>
<A HREF="">Business Owner 2 Value</A>
</span>
</nobr>
</td>
Then I'm trying to put those values in
<input name="ctl00$PlaceHolderMain$g_0ea84a0f_dc84_4456_8f01_af9045c280fd$ff1_1$ctl00$ctl00$TextField" type="text" maxlength="255" id="ctl00_PlaceHolderMain_g_0ea84a0f_dc84_4456_8f01_af9045c280fd_ff1_1_ctl00_ctl00_TextField" title="Title" class="ms-long" />
<input name="ctl00$PlaceHolderMain$g_0ea84a0f_dc84_4456_8f01_af9045c280fd$ff2_1$ctl00$ctl00$TextField" type="text" maxlength="255" id="ctl00_PlaceHolderMain_g_0ea84a0f_dc84_4456_8f01_af9045c280fd_ff2_1_ctl00_ctl00_TextField" title="business owner" class="ms-long" />
<input name="ctl00$PlaceHolderMain$g_0ea84a0f_dc84_4456_8f01_af9045c280fd$ff3_1$ctl00$ctl00$TextField" type="text" maxlength="255" id="ctl00_PlaceHolderMain_g_0ea84a0f_dc84_4456_8f01_af9045c280fd_ff3_1_ctl00_ctl00_TextField" title="Business Owner 2" class="ms-long" />
Based on what I can see in your html
$("td.ms-vb") will return the 3 columns you are interested in.
var data = $("td.ms-vb")
$("#ctl00_PlaceHolderMain_ g_0ea84a0f _dc84_4456 _8f01_af90 45c280fd_f f1_1_ctl00 _ctl00_Tex tField").v al(data(0) .html());
// get the html inside of the a that is in the 2nd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_ g_0ea84a0f _dc84_4456 _8f01_af90 45c280fd_f f2_1_ctl00 _ctl00_Tex tField").v al(data(1) .find("a") .html());
// get the html inside of the a that is in the 3rd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_ g_0ea84a0f _dc84_4456 _8f01_af90 45c280fd_f f3_1_ctl00 _ctl00_Tex tField").v al(data(2) .find("a") .html());
$("td.ms-vb") will return the 3 columns you are interested in.
var data = $("td.ms-vb")
$("#ctl00_PlaceHolderMain_
// get the html inside of the a that is in the 2nd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_
// get the html inside of the a that is in the 3rd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_
ASKER
HMM,,,
That didn't work.
I tried <script>
var data = $("td.ms-vb")
$("#ctl00_PlaceHolderMain_ g_0ea84a0f _dc84_4456 _8f01_af90 45c280fd_f f1_1_ctl00 _ctl00_Tex tField").v al(data(0) .html());
// get the html inside of the a that is in the 2nd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_ g_0ea84a0f _dc84_4456 _8f01_af90 45c280fd_f f2_1_ctl00 _ctl00_Tex tField").v al(data(1) .find("a") .html());
// get the html inside of the a that is in the 3rd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_ g_0ea84a0f _dc84_4456 _8f01_af90 45c280fd_f f3_1_ctl00 _ctl00_Tex tField").v al(data(2) .find("a") .html());
</script>
and
<script>
$(document).ready(function (){
var data = $("td.ms-vb")
$("#ctl00_PlaceHolderMain_ g_0ea84a0f _dc84_4456 _8f01_af90 45c280fd_f f1_1_ctl00 _ctl00_Tex tField").v al(data(0) .html());
// get the html inside of the a that is in the 2nd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_ g_0ea84a0f _dc84_4456 _8f01_af90 45c280fd_f f2_1_ctl00 _ctl00_Tex tField").v al(data(1) .find("a") .html());
// get the html inside of the a that is in the 3rd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_ g_0ea84a0f _dc84_4456 _8f01_af90 45c280fd_f f3_1_ctl00 _ctl00_Tex tField").v al(data(2) .find("a") .html());
});
</script>
That didn't work.
I tried <script>
var data = $("td.ms-vb")
$("#ctl00_PlaceHolderMain_
// get the html inside of the a that is in the 2nd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_
// get the html inside of the a that is in the 3rd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_
</script>
and
<script>
$(document).ready(function
var data = $("td.ms-vb")
$("#ctl00_PlaceHolderMain_
// get the html inside of the a that is in the 2nd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_
// get the html inside of the a that is in the 3rd column with a class of ms-vb, put it into the value of the input with this id.
$("#ctl00_PlaceHolderMain_
});
</script>
The best way to debug this is with FireBug in Firefox, or the developer tools in IE8 or Google Chrome. You can set a breakpoint on the javascript and see what is specifically happening.
I made the assumption that this one row of 3 columns is the only thing that has the class .ms-vb on it. In the developer tools you can verify how many items $("td.ms-vb") is returning. You can also verify that each of the other statements is finding the item that you intend it to.
I made the assumption that this one row of 3 columns is the only thing that has the class .ms-vb on it. In the developer tools you can verify how many items $("td.ms-vb") is returning. You can also verify that each of the other statements is finding the item that you intend it to.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
$("table tr")(1).find("td")
But without knowing what you are specifically trying to get and how it changes, it is hard to give a specific answer. I know I'd probably at least add an id to the table you are interested in to make the selector easier to work with.