PDA

View Full Version : grabbing a <td class="value"> with java script to a form located on another website..



joelnativeenergy
02-08-2007, 09:02 PM
In need of some help. I need to grab a value in the table below, and pre load it into a form on another website. I need to make a form action, that on click will take the value of <td class="carbon"> and drop that value into a form on another website labled "custom_qty"

<table id="summary_totals">
<tbody>
<tr class="totals">
<td class="total_label">Your Totals</td>
<td class="money"> $-21850.00 / $385.53 </td>
<td class="time"> 0 hrs / 0 hrs</td>
<td class="carbon">4544 tons / 2285 tons</td>
</tr>

Let's use http://www.website.com/index.html (placeholder) as the page that contains the final resting spot for the form "custom_qty"

Anyone know how I can do this? if you could help me in writing a form to do so I would be very thankfull!

-Joel

Ruslan Zenin
02-08-2007, 09:10 PM
Wouldn't it be browser security violation (cross-site scripting)?

perhaps you can resort to iframe

mburt
02-08-2007, 09:12 PM
Server-side is your best option, using PHP in this case. What I'll be doing is storing the data in a variable and sending it to another PHP page which recieves the variable contents. It's fairly simple.
Give your carbon td a "name" attribute:

<td class="carbon" name="carbonData">4544 tons / 2285 tons</td>

Now before we go into the next part, I'm assuming you are using a form outside your table:

<form action="newpage.php" method="post">
<table id="summary_totals">
<tbody>
<tr class="totals">
<td class="total_label">Your Totals</td>
<td class="money"> $-21850.00 / $385.53 </td>
<td class="time"> 0 hrs / 0 hrs</td>
<td class="carbon">4544 tons / 2285 tons</td>
</tr>
</table>
<input type="submit" value="Go to page">
</form>

The above button in red will send you to your result page.

When you go to your result page (in this case newpage.php), make these adjustments:

<td class="custom_qty"><?php
$dat = $_POST["carbonData"];
echo $dat;
?></td>

Hopefully this helps