Thank you for taking the time to look at my post.
I have an input tag that i need to have output-ed like so:
<input type="hidden" name="success_redirect" value="http://www.webpage.com?var1=${root/option1}&var2=${root/option2}" />
but i cant get that into my xslt document without it eventually rendering to
<input type="hidden" name="success_redirect" value="http://www.webpage.com?var1=$&var2=$" />
What do i put in the XSLT to allow me to get that value tag to output like i need it to?
Thanks!
Just use:
<input type="hidden" name="success_redirect"
value="http://www.webpage.com?var1=${{root/option1}}&var2=${{root/option2}}" />
Do note that if we want to output a '{' or a '}' in an attribute, we have to double them.
This is because these two characters have special meaning when used inside an attribute: they indicate the start and end of an AVT (attribute-value-template).
You can concatenate the parts:
<input type="hidden" name="success_redirect"
value="{concat('http://www.webpage.com?var1=${','root/option1}','&var2=${','root/option2}')}" />
Related
I would like to take single value from the following strings(HTML tag).
<input type="hidden" name="javax.faces.ViewState" id="j_id1:javax.faces.ViewState:0" value="6857842162548399092:-3372646398158034589" autocomplete="off" />
OR
<update id="j_id1:javax.faces.ViewState:0"><![CDATA[9028765775789786807:-4669779095536779687]]></update>
For <input> tag, the expression is
<input type="hidden" name="javax\.faces\.ViewState" id=".*\:javax.faces.ViewState\:.*" value="[^"]+".*\/>
For <update> tag, the expression is
<update .*><!\[CDATA\[(.*?.*)\]\]><\/update>
In need single result 685784..89 or 90287..87.
The expression have to get single result for <input ...> or <update....>.
You can combine the two with an |("OR").
Assuming the PCRE regex flavour:
(?|(?:<input type="hidden" name="javax\.faces\.ViewState" id=".*\:javax.faces.ViewState\:.*" value="(?<value>[^"]+)".*\/>)|(?:<update .*?><!\[CDATA\[(?<value>.*?)\]\]><\/update>))
Explanation
I have about 1,000 lines of html that look like this:
<input type="text" readonly value="some-value-here" class="unit size1of2" />
I am able to find all of those lines using the RegEx search of
<input type="text" readonly value="[^<]+" class="unit size1of2" />
However, I am trying to change all of them to
<input type="hidden" value="same-value-that-was-found" />
Any ideas on what I need to do to accomplish this?
In coldfusion, in the hidden values of a form I get two values:
<input type="hidden" name="EST_VAL" value="#EST_VAL#" />
<input type="hidden" name="DOWN_PMT" value="#DOWN_PMT#" />
I need to find the value of EST_VAL subtracted from DOWN_PMT and assign it to this value:
<input type="hidden" name="LOAN_VAL" value="#LOAN_VAL#" />
I know how to do this in PHP, but I'm not sure if I should use a cfset, or cffunction in coldfusion.
you can do this inline with pound signs like so:
<input type="hidden" name="LOAN_VAL" value="#EST_VAL-DOWN_PMT#"/>
CFSET should be all you need for this. Without seeing the other code in this file/script, a simple approach/solution would entail the following:
<cfset LOAN_VAL = EST_VAL - DOWN_PMT />
That would then output the value of the LOAN_VAL variable in the hidden field tag you note in your original post.
I need a regex to match all self-closing <input /> tags which lacks a type attribute.
For example, I want to find these:
<input size="1" />
<input name="test" />
But not this:
<input type="radio" />
Please note, this should be adaptable for any single attribute. I am just using type here as an example.
FYI, I am performing a search across 1000s of .html files using AstroGrep.
You can assume that the attribute is well-formed, with equals sign and double quotes.
<input(?:\s+(?!type=)\w+="[^"]*")*\s*/>
That should work if AstroGrep's regex flavor isn't too exotic. I can't find an online reference for it.
I don't know what is AstroGrep, but if it has negative look-ahead, you could just do
(?!\<input(?:[[:space:]]+[a-zA-Z0-9_]+="[^"]*")*(?:[[:space:]]+type="[^"]*"))<input(?:[[:space:]]+[a-zA-Z0-9_]+="[^"]*")*[[:space:]]*/>
Without it, it is much more laborious.
UPDATED - since I was not clear in me expressions. Will try again:
I have a form with several inputs that are created dynamically like this:
<form id="tellafriend_form" method="post" action="landingpage.aspx">
<!-- static example -->
<input type="text" id="my_example" name="my_example" value="" />
<!-- dynamic part -->
<xsl:for-each select="something">
<xsl:variable name="publicationId" select="#id"/>
<input type="text" id="{$publicationId}" name="{$publicationId}" value="" />
</xsl:for-each>
</form>
When submitted how do I get the value from the input using xslt? I can get it from the static input field but not from the dynamic fields since I do not know there names/ids.
I know that all $publicationId will be an integer greater than 2000 but less than 4000. If needed they can easily be prefixed with some text (if numbers alone make a problem).
An XSLT solution would be preferred. Or using jQuery if that could do the trick (saw this, that may be another solution: Obtain form input fields using jQuery?).
BR. Anders
landingpage.aspx won't be able to identify the relevant POST values as you never know in advance the input element name.
This suggests you'd need to augment the name with some additional data which you do know in advance. That is, add in extra information to the name that you can check for later.
A good choice is to append the names in such a way that the receiving script is able to (automatically) interpret them as an array. This is then easier to deal with in the receiving script. One such way, dependent on what the receiving language/framework allows, is:
<form id="tellafriend_form" method="post" action="landingpage.aspx">
<!-- static example -->
<input type="text" id="my_example" name="my_example" value="" />
<!-- dynamic part -->
<xsl:for-each select="something">
<xsl:variable name="publicationId" select="#id"/>
<input type="text" id="{$publicationId}" name="publication[{$publicationId}]" value="" />
</xsl:for-each>
</form>
Try this and examine the publication value in the POST data. You may find this is an array or hashmap. For this to work you would need to use the correct representation for an array of data within a form as far as the receiving language is concerned.
Another option is to augment the input names with a known identifier and then, within the receiving script, check all POST field names for the relevant identifier. For example:
<form id="tellafriend_form" method="post" action="landingpage.aspx">
<!-- static example -->
<input type="text" id="my_example" name="my_example" value="" />
<!-- dynamic part -->
<xsl:for-each select="something">
<xsl:variable name="publicationId" select="#id"/>
<input type="text" id="{$publicationId}" name="publication{$publicationId}" value="" />
</xsl:for-each>
</form>
Iterate through all the received POST name:value pairs and check for those whose name begins with 'publication'.
For this to work you must choose a prepend value that does not occur within an actual publication ID. I'm assuming here that a publication ID is numeric, hence any meaningful non-numeric prepend value (such as 'publication') would be appropriate.