We help IT Professionals succeed at work.

xml use in mailto and target element of <a href> tag .....

Medium Priority
1,717 Views
Last Modified: 2013-11-19
Hi,

I have a very unique rpoblem.

I am using the datasrc - datafld element of xml in a a table for getting cotent for my page.

Now, in every td of the table, i have a mailto: link which - when clicked the the web url should be inserted in the email body part. Baiscally, i want to insert the xml node value in the mailto: subjecct part, like the way we attach to the table by :

<a class="mySpacelinks" href=<span datafld="urlitem"></span><span datafld="urllabel"></span></a>

I tried adding span to the mailto body, but it gives me <span datafld="urlitem"></span> in the body and the not the actual url.

Pls help.

Also, in the html page with href links, i want to add "target" element in it with the value for it coming from an xml file, similar like adding target=<span datafld="target"></span>. i tried it in anchor elemtn but it gives me error and not correct output.

Pls help.
Comment
Watch Question

Commented:
sounds not very clear to me.

may be you post what do you have and the result you want to achieve?

Commented:
Single valued consumers automatically bind to the correct attribute.  For example, if you have:

[...]
<xmlNode>
    <urlitem>mailto:rdcpro@hotmail.com</urlitem>
    <urllabel>Mike Sharp</urllabel>
</xmlNode>
[...]

then this should work:

<a class="mySpacelinks" datafld="urlitem"><span datafld="urllabel"></span></a>

assuming this is in a table that provides the datasrc attribute.  Otherwise, you'll need to add the datasrc to the anchor.

Regards,
Mike Sharp

Author

Commented:
mike, i want this line in the urlitem :

mailto:?subject=Please visit this link&body=https://www.mphasis.com

I added this in xml but there is no output and sort of error- no xml contents are loaded in the asp file.

Any ideas

Author

Commented:
any body there??

Commented:
hm...may be you post your xml/xslt/asp code? just we can see ?

Author

Commented:
the table is :

<table cellpadding="1" cellspacing="1" border="0" dataSrc="#Articles" width="95%">
                                                                                    <tr>
                                                                                    <td height="16" colspan="2"><img src="B2E/images/spacer.gif" width="1" height="12" border="0" alt=""></td>
                                                                                    </tr>
                                                                                    <tr>
                                                                                    <td colspan="2"><a target="_blank" class="shortlinks" href=<span datafld="urlitem"></span><span datafld="urllabel"></span></a></td>
                                                                                    </tr>
                                                                                    <tr>
                                                                                    <td colspan="2" class="popuptext"><span datafld="description"></span></td>
                                                                                    </tr>      
                                                                                    <tr>
                                                                                    <td colspan="2" class="sourceText"><span datafld="author"></span></b></td>
                                                                                    </tr>      
                                                                                    <tr>
                                                                                    <td colspan="2" class="sourceText"><span datafld="source"></span></td>
                                                                                    </tr>
                                                                        <tr>
                                                                                    <td class="popuptext" width="40"><img src="B2E/images/Envelope.gif"></td>
                                                                                    <td width="93%">
<a class="textlinks1" href=<span datafld="mailinfo"></span>Post this to your colleague</a>
                                                                                    </td>
                                                                                    </tr>                                          </table>

now everyhting works fine and all data frm my Articles.xml file is shown BUT when in the mailinfo xml tag, i put - mailto:?subject=Please visit this link&body=https://www.mphasis.com, it gives me error.

The purpose is that i get the mailto: in the a href tag WITH THE SPECIFIC PAGE URL THAT I want to be added in the email.  

You can suggest me other ways. I tried to access the <span datafld="mailinfo"> in the javascript variable but got errors. I had plan then to use this js variable in the document.write(<a href="mailto:?subject=demo&body" + valueofspanfrmjavascript.


                                                                              

Commented:
No, you're not doing as I suggested.  Don't try to put a span tag in an attribute--that doesn't work; it's not well-formed HTML.  Just bind the anchor tag to the datafield.  The DSO will provide an href attribute, and put the contents of the field in there automatically.

<a class="mySpacelinks" datafld="mailinfo"><span datafld="urllabel"></span></a>

The anchor tag works *exactly* like a span tag--you bind the tag, not the attribute.  The DSO knows that an anchor tag that's bound gets its href attribute bound.  So make sure your anchor tag is like mine, NO href attribute, and just a single datafld attribute.

Regards,
Mike Sharp

Author

Commented:
mike,

i want to put this part :

mailto:?subject=Please visit this link&body=https://www.mphasis.com

in the 'mailinfo' xml tag in my xml file, so that when the page is loaded - the anchor elements href part has the respective "mailto.....with body email subject" i want.

Is it possible?i tried but gives me an error output.

Can u try 4 me. Gr8 if u can do it

Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.