Jump to content

AquariaXI

Members
  • Posts

    32
  • Joined

  • Last visited

AquariaXI's Achievements

Member

Member (2/5)

0

Reputation

1

Community Answers

  1. Someone can help? This person obviously doesn't want to really help me...
  2. This makes absolutely no sense to me. I learn by example. I simply want to use // Find all <td> whose attribute id="BLAH" $doc = new DOMDocument ( ); $doc -> loadHTMLFile ( 'index.php' ); $child = $doc -> getElementsByTagName ( 'td' ); foreach ( $child as $td ) { if ( $td -> hasAttribute ( 'id' ) ) { echo $td -> attributes -> getNamedItem ( 'id' ) -> nodeValue . '<br>\r\n'; } } Now, this returns "colors" which is the id. not the value OF colors. It also comes with a warning It at least SEEMS to me at the moment at least, that you are simply trying to avoid the answer.
  3. As the title says, how can i check if multiple arrays exist inside an array or not? Any help is greatly appreciated!
  4. I didn't ask you to do it for me. I simply asked for how I can grab getElementFromId data in PHP from jquery using DomDocument...
  5. Isn't there a way to use <?php // Create a new DOM Document $dom = new DOMDocument('1.0', 'iso-8859-1'); // Enable validate on parse $dom->validateOnParse = true; // Create a div element $element = $dom->appendChild(new DOMElement('div', 'Hey, this is the text content of the div element.')); // Create a id attribute to div $attr = $element->setAttributeNode( new DOMAttr('id', 'my_id')); // Set that attribute as id $element->setIDAttribute('id', true); // Get the tag content $tagcontent = $dom->getElementById('my_id')->textContent; echo $tagcontent; ?> ? except i don't want a div, i want the td's "shades" & "tints"
  6. I don't want to have to submit it. The "Update" button does not "submit", it just instantly changes the hex values.
  7. Correct. I just want to echo out the chosen hex values from within the "shades" td & "tints" td id tags When the user interacts with the "Update" button, when they hit it, it changes the tints / shades hex values that are held within the "shades" id & "tints" id td tags.
  8. ding ding ding! CORRECT! The user DOES interact with the page to change what values are being shown in the table. anyway, this is the table : <table class="color_frame"> <tr> <td class="picker_box"> <div class="color_wrapper"> <div id="colorpickerHolder"></div> <div class="top_bar"> <div class="color_panel"> <!--Color Panel--> </div> </div> <input type="button" value="&nbsp;" class="update_btn" /> </div> </td> <td class="color_map"><img src="images/color_map.gif" alt="Shade and Tint map" /></td> <td id="colors" class="shade_box"> <table id="shades"></table> <table id="tints"></table> </td> </tr> </table>
  9. function hex2rgb ( hex ) { hex = hex.replace ( '#', '' ); r = parseInt ( hex.substring ( 0, 2 ), 16 ); g = parseInt ( hex.substring ( 2, 4 ), 16 ); b = parseInt ( hex.substring ( 4, 6 ), 16 ); result = 'rgb(' + ( r + ', ' + g + ', ' + b + ')' ); return result; } function rgb2hex ( rgb ) { rgb = rgb.match ( /^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i ); return ( rgb && rgb.length === 4 ) ? "#" + ( "0" + parseInt ( rgb [ 1 ], 10 ).toString ( 16 ) ).slice ( -2 ) + ( "0" + parseInt ( rgb [ 2 ], 10 ).toString ( 16 ) ).slice ( -2 ) + ( "0" + parseInt ( rgb [ 3 ], 10 ).toString ( 16 ) ).slice ( -2 ) : "" } for ( var i = 0; i < 10; i++ ) { var shadeHex = rgb2hex ( String ( 'rgb(' + shades [ 9 - i ].rgb + ')' ) ); var tintHex = rgb2hex ( String ( 'rgb(' + tints [ i ].rgb + ')' ) ); $ ( "#shades" ).append ( '<tr>' + '<td class="hexcolor">' + '<a style="background : ' + shadeHex + '"></a>' + '</td>' + '<td class="hexcode">' + shadeHex + '</td>' + '</tr>' ); $ ( "#tints" ).append ( '<tr>' + '<td class="hexcolor">' + '<a style="background : ' + tintHex + '"></a>' + '</td>' + '<td class="hexcode">' + tintHex + '</td>' + '</tr>' ); } this is my whole jquery code
  10. i dont understand... T_T I said the jquery is serving up the tds : $ ( "#shades" ).append ( '<tr>' + '<td class="hexcolor">' + '<a style="background : ' + shadeHex + '"></a>' + '</td>' + '<td class="hexcode">' + shadeHex + '</td>' + '</tr>' );
  11. How would YOU do it then? I've been trying to figure out how to grab the `td` `shades` data from php for 18 hours now.
  12. Yes & ONLY grab the value{s} between "<td id=\"shades\">DATA HERE</td>" - It is to grab the color hexes from my jquery hex array & echo them out in php. and NO I cannot build the table in PHP. the hex values are generated from jquery ONLY & are put inside the table with the id, "shades"
  13. Made a typo HTML [ 0 ] = $string; should be $HTML [ 0 ] = $string;
  14. So I'm trying to grab values from a specific table id in html in PHP possibly using `DOMElement` or something else? I want to add my index.php page to a variable, search for a certain table id ( in this case, "shades" ), then grab JUST the values from inside that table & print it out in an echo. Here's what i have. for some reason I'm getting Warning: DOMDocument::loadHTML(): htmlParseEntityRef: no name in Entity <?php $HTML = [ ]; $stream = fopen ( "index.php", "r" ); $string = stream_get_contents ( $stream ); HTML [ 0 ] = $string; // Our HTML goes here $innerHTML = implode ( ',', $HTML ); // Create a new DOMDocument based on our HTML $document = new DOMDocument; $document -> loadHTML ( $innerHTML ); // Get a NodeList of any table "id", "shades" $cells = $document -> getElementsByTagName ( "id" ); // Cycle over each <td>, adding its HTML to $innerHTML foreach ( $cells as $cell ) { $innerHTML = $document -> saveHTML ( $cell ); } // Output our glorious HTML echo $innerHTML; fclose ( $stream ); ?> Any help is absolutely appreciated!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.