Triggering postback to send query parameters from DVWP dropdown box - xslt

I need to filter my list based on selected dropdown value. I've created a DVWP for that and converted it into a dropdown. Now I'm following this post to fire events when dropdown value is selected but I just do not know where to change the code. I'm filtering the list based on years. I have an year list which stores year values and filters it accordingly when the dropdown is selected. I've modified it like this:
<xsl:otherwise>
<select name="ID" size="1" onchange="document.location.href='pageName.aspx?year=' + this.options[selectedIndex.value])">
<option selected="true" value="0">Choose One...</option>
<xsl:call-template name="dvt_1.body">
<xsl:with-param name="Rows" select="$Rows" />
</xsl:call-template>
</select>
I've no idea of xslt and this isn't firing any event when i change the dropdown value. Please help me with this.
Update: The HTML I get:
<td valign="top">
<div WebPartID="9e0da2fd-21ea-417f-863d-6551d16e72a1" HasPers="false" id="WebPartWPQ3" width="100%" class="noindex" allowDelete="false" style="" >
<select name="ID" size="1" onchange="document.location.href='http://pageName.aspx?year=' + this.options[selectedIndex].value" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
<option selected="" value="0">Choose One...</option>
<option>2009</option>
<option>2010</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
</select>
</div>
</td>

I'm somewhat doubtful that this is an XSLT issue. The script for the onchange handler in that tutorial seems to boil down to:
document.location.href='pageName.aspx?year=' + this.options[selectedIndex].value
Note that .value is outside the []. Could you give that a try? Is your browser reporting any JavaScript errors when you change the dropdown selection?
Now, according to this tutorial, you can filter a list by specifying query parameters named FilterField1, FilterValue1, etc, so could you try something like this:
document.location.href='pageName.aspx?FilterField1=ColumnName&FilterValue1='
+ this.options[selectedIndex].value + '&year=' + this.options[selectedIndex].value
Here you would replace "ColumnName" with the actual name of the column, as indicated in that tutorial. Could you try something like that?

Related

Passing values from Django template to javascript-ajax function

Now my template displays a table having a link on each row to display more details. Each row passes unique column_name, db_name, schema_name, tablenm combination to get more details.
<td>
<a href="{% url 'moreDetails' column_name=row.colname db_name=row.dbname schema_name=row.schemaname table_name=row.tablenm %} " target="_blank">
Values
</a>
</td>
The above code works , but open a new window for the result set. But, I would like to route it through a javascript(Jquery-django) and capture the result back in Javascript and display the result as a javascript message without refreshing the complete page.
How Can I pass there values (column_name, db_name, schema_name, tablenm) to the java script on the click event
I tried replacing href with button and set a value to it
<td>
<input type="button" value={% row.colname |","| row.dbname |","| row.schemaname |","| row.tablenm %} class="apireq" />
<td>
But seems not working. I welcome any help on this . Thanks In advance
Why not set them as data attributes?
<input type="button" class="apireq"
data-colname="{{row.colname}}"
data-dbname="{{row.dbname}}"
data-schemaname="{{row.schemaname}}"
data-tablenm="{{row.tablenm}}"
/>
Then in your click event handler you will have a reference to the button that generated the event, all you need to to is read the attributes off of it. And they are already parsed out so no worries there too.

how to insert single checkbox value in coldfusion code

I have a single checkbox, I want that when I check the checkbox it
should insert 1 else 0 in the database. How can I do that? This was
earlier a radio button field which is getting converted to check box so
already entry in the database is working good, I am posting my database
code as well.
<tr>
<td class="leftFormLabelCell extrasmalltextbold" style="border-
left:1px solid ##9c9c9c;" width="15%">
#mocTrans.Translate("Required template Action Item?")#
</td>
<td>
<input type="checkbox" name="reqtempactionitem" value="0">
</td>
</tr>
Databse code:
<cfif StructKeyExists(URL, "reqtempactionitem") and
IsBoolean(URL.reqtempactionitem)>
, #reqtempactionitem#
<cfelse>
, 0
</cfif>
The way html checkboxes work is that if checked, the browser will submit [checkboxname]=[value] to the webserver. If the box is not checked, the browser does not submit anything at all to the server.
So the easiest solution uses cfparam, which will give the submitted checkbox a default value.
Thus, in your html, you should have:
<input type="checkbox" name="reqtempactionitem" value="1">
(As has been noted in comments, your value was 0 and should be 1.)
Then, in the database code:
<cfparam name="reqtempactionitem" default="0">
...
dbfield = <cfqueryparam cfsqltype="cf_sql_bit" value="#reqtempactionitem#">
Note the use of cfqueryparam, which is strongly recommended in all queries for both performance and security reasons.

try to get my cfdiv to load on the same page

I have a page that provide some information and a cfselect tag.
<cfform name="selectrate" method="post" format="html">
<cfselect name="rateid" query="getrate" value="rateid" display="ratecode" />
</cfform>
<cfajaximport tags="cfform">
<cfdiv id="rateDiv" bind="url:testniva_3.cfm?rateid={rateid}" style="height:1500" bindonload="true">
For each rateid that is selected the cfdiv will call on testniva_3.cfm which provide information for that rateid. The testniva_3.cfm has a <cfsavecontent> tag that will calculate the grandtotal for the cfgrid in the same page. The testniva_3.cfm has this code:
<cfform name="display" format="flash">
<cfgrid name= "cart" query="getdtls" selectmode="edit" width="580">
<cfgridcolumn name="chargename" header="Charge Type" dataalign="right" select="No" >
<cfgridcolumn name="price" header="price"type="numeric" dataalign="right" select="No" >
<cfgridcolumn name="quantity" header="Quantity" type="numeric" dataalign="right" >
</cfgrid>
<cfinput type="Button" name="calculateBtn" value="Calculate Order" onclick="#calculateTotal#">
<cfinput type="Text" name="total" disabled="true" label="Total $" size="5">
</cfform>
The cfdiv seems to bind with the cfselect tag, because when I change the option in cfselect, the data in testniva_3.cfm page also changes, however, instead of remain on the page with all the information and the select option, it give me an error: Error processing JavaScript in markup for element rateDiv: [Enable debugging by adding 'cfdebug' to your URL parameters to see more information
then when I click OK, it refreshs the page and just give me the testniva_3.cfm page without all the information and select option of the main page. If I change the format of the cfgrid on the cfform in the testniva_3.cfm page to html, then the grid refresh the data without any problem, however, my <cfsavecontent>#calculateTotal# will not work with html format.
I am not sure what went wrong, and how to fix it. Any one have any ideas? I would really appreciated.
Thank you.

Umbraco : displaying an image using the XSLT

I'm pretty new to umbraco but found the system pretty easy to use and have done alot in a short space of time. One difficulty I have come accross is displaying an image.
In the document type I have added an "upload" where an image is selected.
In my XSLT I loop through the pages, this loop displays the other fields such as description or title. I am trying to display the image here.
Here is my XSLT for displaying my image, this displays nothing. The field "promothumbImage" is defined in the document type, as I said everything else is working fine.
<xsl:value-of select="promothumbImage"/>
Does anyone have any ideas as to where I am going wrong?
EDIT:
promothumbimage is defined in the document of type "upload"
My XSLT:
<!-- The fun starts here -->
<div class="promoitems">
<xsl:for-each select="umbraco.library:GetXmlNodeById($source)/* [#isDoc and
string(umbracoNaviHide) != '1']">
<div class="promoitem">
<a href="{umbraco.library:NiceUrl(#id)}">
<xsl:value-of select="#nodeName"/>
</a>
<div class="promosmalldesc">
<xsl:value-of select="promoSmallDesc"/>
</div>
<xsl:copy-of select="promothumbImage/*"/>
</div>
</xsl:for-each>
Upload means that the element promothumbImage returns the URL of the image, thus the following should display it on the page:
<img src="{promothumbImage}" alt=""/>
I found the answer, use:
<img src="{promothumImage}" />
to display the image from the "upload" set in the document type
use may simply in your template using your image field throght Media picker Data Type:
<img class="className" src='<umbraco:Item field="infoGraphic" runat="server" Xslt="umbraco.library:GetMedia({0},false())/umbracoFile"/>'/>

xslt form fields - get input with unknown name

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.