PDA

View Full Version : Which format of do I use for setting an attribute ?



jeddi
01-22-2011, 02:28 PM
I am trying to get my script working in FF, IE and Opera
but the getAttribute isn't working for me.

The domain name isn't getting picked up :(

I have tried this:

var dom_name = document.getElementById('dom_nm').getAttribute("value",2);

and this:

var dom_name = document.getElementById('dom_nm').getAttribute('value');


After this I use the domain name like this:


if (per2 == 0) {
item_desc = "Domain Name and DNS set up. Domain: "+dom_name+" Period: "+per1+"year"+" No Privacy.";
}

if (per2 > 0){
item_desc = "Domain Name and DNS set up. Domain: "+dom_name+" Period: "+per1+"year"+" Including: Privacy: "+per2+"year.";
}


document.getElementById('item_pay').setAttribute("value","item_desc");


( I also tried:


document.getElementById('item_pay').setAttribute('value') = item_desc;

but that didn't seem to work either )


The HTML is like this:



<div style="margin: 5px auto;">
<table>
<th>Your New Domain Name Order</th>
<tr><td>Product</td><td>Cost</td><td>Years (max. 10)</td><td style="text-align: right;">Total Cost</td></tr>
<tr><td id="dom_nm" value="John.Doe"><?php echo "Domain: $N_dom.$N_tld" ?></td><td id="price" value = '<?php echo "$priceN" ?>' ><?php echo $priceN ?></td><td><input style="background-color: yellow; font-weight: bold;" type='TEXT' id="per_1" size = '10' value = '<?php echo "$period_1" ?>' ></td><td><input type='TEXT' id="total_1" style="text-align: right;" value = '<?php echo "$total_1" ?>'></td></tr>
<tr><td>Domain Privacy</td><td>8.70</td><td><input style="background-color: yellow; font-weight: bold;" type='TEXT' id="per_2" size = '10' value = '<?php echo "$period_2" ?>'></td><td><input type='TEXT' id="total_2" style="text-align: right;" value = '<?php echo "$total_2" ?>'></td></tr>
<tr><td>Total Order.</td><td> --- </td><td> --- </td><td><input type='TEXT' id="total_3" style="text-align: right; font-weight: bold;" value = '<?php echo "$total_3" ?>'></td></tr>
</table>
</div>


The result is that I get a zero ( 0 ) where the domain should be.

Like this:
Domain Name and DNS set up. Domain: 0 Period: 2year Including: Privacy: 2year. Plus Free Blog Install.


Any ideas what I am doing wrong ?

Thanks

abduraooft
01-22-2011, 02:33 PM
<td id="dom_nm" value="John.Doe">
How about using a hidden <input> element and document.getElementById('dom_nm').value instead?

jeddi
01-22-2011, 02:46 PM
The John.Doe was for testing to see if it gets picked up at all.

My HTML is:


<table>
<th>Your New Domain Name Order</th>
<tr><td>Product</td><td>Cost</td><td>Years (max. 10)</td><td style="text-align: right;">Total Cost</td></tr>
<tr><td id="dom_nm" value='<?php echo "$N_dom.$N_tld" ?>'><?php echo "Domain: $N_dom.$N_tld" ?></td><td id="price" value = '<?php echo "$priceN" ?>' ><?php echo $priceN ?></td><td><input style="background-color: yellow; font-weight: bold;" type='TEXT' id="per_1" size = '10' value = '<?php echo "$period_1" ?>' ></td><td><input type='TEXT' id="total_1" style="text-align: right;" value = '<?php echo "$total_1" ?>'></td></tr>
<tr><td>Domain Privacy</td><td>8.70</td><td><input style="background-color: yellow; font-weight: bold;" type='TEXT' id="per_2" size = '10' value = '<?php echo "$period_2" ?>'></td><td><input type='TEXT' id="total_2" style="text-align: right;" value = '<?php echo "$total_2" ?>'></td></tr>
<tr><td>Total Order.</td><td> --- </td><td> --- </td><td><input type='TEXT' id="total_3" style="text-align: right; font-weight: bold;" value = '<?php echo "$total_3" ?>'></td></tr>
</table>


Not sure if an input would work here ?

Maybe it would make more sense if you see the page:

http://heavyhoster.com/thankyou_profplus.php

You need to scroll right to the bottom - insert a domain - eg hyetf45.com
then hit Check, then when it says it is available hit "Select and Continue"

The page that then comes up is the one with this table on.

(sorry but thats the quickest way to see the table )

Thanks for your help :)