locked
Help creating href RRS feed

  • Question

  • User-1450801863 posted

    I'm trying to build a simple href that will pass a xsl value in the link. I don't understand the original code and my code is not working. Its saying I have html errors. However we dont have a good compiler so I dont know what the error is exactly.

    code:

    <!--Original Code
    	<a>
    		<xsl:attribute name="class">drilldownlink</xsl:attribute>
    		<xsl:attribute name="href">javascript:void();</xsl:attribute>	
    		<xsl:attribute name="onclick">toggle_visibility('<xsl:value-of select="inv_code_cp" />');</xsl:attribute>
    		<img>
    			<xsl:attribute name="src">images/img_plus.gif</xsl:attribute>
    			<xsl:attribute name="border">0</xsl:attribute>
    			<xsl:attribute name="name">img_<xsl:value-of select="inv_code_cp" /></xsl:attribute>
    			<xsl:attribute name="id">img_<xsl:value-of select="inv_code_cp" /></xsl:attribute>
    		</img>
    		<xsl:value-of select="inv_code_cp" /> 		
    	</a>-->
    	<!-- New Code <a href="dynamicpage.aspx?Webcode=OrderHistorydetail&inv_code={inv_code_cp}" target="_blank"><xsl:value-of select=”inv_code_cp” /></a>-->

    Javascript from original:

    <script type="text/javascript" src="include/CFAHAAsyncLoadIVD.js"></script>
    <script type="text/javascript">
    	function toggle_visibility(id)
    	{
    		var ivd='ivd_' + id;
    		var img='img_' + id;
    		var cst_key = $('#cst_key').val();
    
    		var i = document.getElementById(img);
    		if(i.src.indexOf("images/img_plus.gif") > 0)
    			i.src = 'images/img_minus.gif';
    		else
    			i.src = 'images/img_plus.gif';
    			
    		var e = document.getElementById(ivd);
    		if(e.style.display == 'block')
    			e.style.display = 'none';
    		else
    		{
    			e.style.display = 'block';
    			
    			//call Async page.
    			CFAHAASyncLoadIvd(id, ivd, cst_key);
    		}
        }
    </script>

    Tuesday, November 6, 2018 2:58 PM

All replies

  • User475983607 posted

    The original code is XSLT.  XSLT is used to convert and XML to another format.  In this case it looks like XML is converted to HTML.  The XSLT shown expects a specific XML format that describe an link.  I recommend that you meet with your team for an overview of how the application works.  Usually the XML is dynamic and the XSLT does not change as the XSLT defined the conversion.

    https://www.w3schools.com/xml/xsl_intro.asp

    Tuesday, November 6, 2018 3:26 PM
  • User-1450801863 posted

    Thanks but I'm trying to understand why my new code is not working. My link is based off the original code. It should grab the value of the XSLT so i can use it like a variable. This issue is its not letting me. 

    Tuesday, November 6, 2018 3:49 PM
  • User475983607 posted

    mholmesAHA

    Thanks but I'm trying to understand why my new code is not working. My link is based off the original code. It should grab the value of the XSLT so i can use it like a variable. This issue is its not letting me. 

    The new code is not even close to the original code.

    The original code toggles visibility of DOM nodes like a plus/minus.  The new code builds a link which reloads the DOM with new content.

    Can you explain the problem you are trying to solve at a high level and provide the error message?

    Tuesday, November 6, 2018 4:49 PM
  • User-1450801863 posted

    Hmm well my goal is to just redirect users to a new web page and pass in that invoice code in the url. So I'm a little unsure why its not working. 

    Wednesday, November 7, 2018 3:23 PM
  • User475983607 posted

    Phrases like "not working" and "HTML errors" are not specific enough to provide an accurate solution.

    Wednesday, November 7, 2018 3:38 PM
  • User753101303 posted

    Always start with what happens. Do you have an error message? What if using "view source" in your browser to see the difference between the HTML markup you want and the HTML markup you currently produce and see what needs to be adjusted? Maybe the text link is ok but the {inv_code_cp} placeholder is not processed ?

    It's always best to just see the difference between what happens and what you want to happen rather than giving others some code to read and let them wonder which bad thing happens among all bad things that could happen.

    Not directly related but XSLT seems overkill ? Using a Web Forms or Razor view engine doesn't fit your need ?

    Wednesday, November 7, 2018 4:18 PM