Aspx page :
fileupload
dropdownlist subject
Textarea
User can write anything in textarea.There is no sequence, that user can first write text or upload file.Dropdownlist has onchange and selected indexchanged event.Onchange event calling javascript function which convert '<',to it's html encode character if textarea contain.On selectedindex change appropriate script of that subject code get added into textarea replacing previous one.It is not necessary that user should select subject for script,can write it's own.Every thing is working properly over here.When I selecting file other than text I want hide dropdownlist subject and want to make index at zero.
Suppose I uploaded text file,selected subject which inserted script into textarea,now I want to select img rather than text file,if I do, dropdownlist get disable and show first value document.getElementById('ddlSubject').selectedIndex = 0.Textarea is empty.Every thing is working properly here .But when I again select textfile,textarea and dropdownlist get enable.If I choose one subject which was selected previously,serverside event of dropdownlist did not get fired.If I choose other subject it call server side function.How to handle this
Please make sure you have the property of the control set as AutoPostBack = true. Furthermore, it'll be easier if you could share a code snippet.
Related
I have a listbox in an Adobe Acrobat form. When I change the value of the listbox, the source of the image field has to be changed with a javascript script:
As a first step, I tried to change the src in javascript, so not yet with the listbox:
var logo = this.getField("companylogo"); // button field
logo.buttonImportIcon("C:\Users\VincentJanssens\Downloads\Blauw.png")
But even this code isn't working.
Thank you for getting me started!
The code can be very simple if you set the fields up to allow for that. The first step is to create buttons for each of the images you want to be available. Name these buttons such that the Export Value of the item in the Dropdown matches exactly. Set these buttons to Hidden and Read Only in the General tab.
Then add a button where you want the various images to appear on your form. Set this field to read-only too. Now, set up the Dropdown to Commit the selected value immediately and add the following JavaScript to the Format script of the dropdown. Replace the string 'displayImage' with the name of the button field you placed on your form.
this.getField("displayImage").buttonSetIcon(this.getField(event.target.value).buttonGetIcon())
Now each time the list item changes, the script will run and use the Export Value of the field to get the button icon from the button with the same name as the export value.
I've posted a working example file here.
Almost got my script running but I hit a roadblock. What I am currently trying to accomplish is filling a select list based on text input and vice versa. In my web application I have a text input which is read only and is usually dynamically populated and then transferred over to a multi select list where end users can only modify the text input from the multi select list.
Here is what I had so far: http://jsfiddle.net/akhyp/1983/
$("#hidden_input").val(function(e){
var ar = $(this).val().split(",");
$("#selected_items option").each(function(){
if(ar.indexOf($(this).val()) != -1)
$(this).attr("selected","selected");
});
});
$('#selected_items').change(function(){
$('#hidden_input').val($('#selected_items').val());
});
Now im still learning jquery but looked at the jquery API documents on events and .val seem to be the best fit for capturing my text input. However got some unexpected results where jquery removes the values that were dynamically added however it does end up properly selecting the appropriate option from my multi select list.
Im thinking the problem is maybe with my .change event of the select list where its not returning the data back to input. What I need at the moment is something like so:
-If the text input is null then ignore.
-If the text input is already filled then capture value and transfer it to the select list accordingly.
-If user select new options from the multi select list then capture new selected options and transfer them over to the text input.
I know its probably something I may have overlooked but I would appreciate any support on this.
I have a textbox and a button (that says "Activate"). Once the value of the textbox is changed, the text on the button changes to "Search". In the code-behind, it checks whether the button's text says Search or Activate and has different course of actions to be executed for each. But when I click the button while it says "Search" on it, the action it still executes is for when it says "Activate".
This is the function I used which gets called by the textbox's OnKeyDown and OnPaste events:
function changeButtonText(){
var elem = document.getElementById("btnactivate");
if (elem.value=="Activate")
elem.value = "Search";}
I want to know why this happens. Clearly the button displays "Search" already. I don't get why the code-behind doesn't seem to recognize the change in the button's text. Btw, when I click the button again, it executes the action for "Search" then. I'm confused. Help!
Any http post back information only related to input types , label information are never posted. If you want to get them on the server side use the hidden fields In you javascript update the value of hidden field part of your FORM tag and then check its value on the server side and do what you want to do
I have an HTML select element (combo box) in a form with a couple if options in it. As always each option has a specific value. During the page's initialization I get a value from the server that I must use as the selected option in the list. Sometimes however I get a value from the server that does not match any of the available options. (grrrr)
I want to let the user know that the value I got from the server is not a valid option. What I'd like to do is show an empty select box (as if no selection was made) without having an actual empty option as one of the options. Also I'd like to use the default select element if possible. Is something like this possible?
Edit: When you set the value for a combox to '' in IE9 (I used $('select').val('') ) it empties the text in the combo box which is exactly what I need. Unfortunately only IE9 does this, so this is not an option.
Out of the box, HTML selects do not provide such functionality. You will have to add an empty <option value="somethingwrong">Please, pick a value</option> element and use scripting to check if the user has selected this specific value. I'd suggest catching both onchange event of the dropdown and onsubmit event of whole form.
You can insert option in select, and remove that whenever it is changed to reduce problems with that options
Check the Demo here
I'm very new to JavaScript and HTML.
I have a simple html form that has some select fields. When the user selects the options from the fields, a function is called that takes the values of the fields, multiples the values against other field values and spits out the results to an input text field named "result".
This is all working great, however I would love a way that instead of outputting the results to a text field, it would output as standard text on the page.
What I did was call the calculate function the tag, within the body, I inserted a document.write(result), then I created a button that calls the calculate function in addition to location.reload().
In Firefox, it works perfectly where it KEEPS the options selected, calculates the results, reloads the page and updates the document.write(result) value on the page.
But in IE or Safari, it resets the select options values to the default settings.
I hope this makes sense and appreciate any help!
how about this:
every time the user selects an option, or makes any sort of a selection, serialize that control, and slap the serialized string to the end of the current window.location, then navigate to it.
also, you will need to add javascript to check the current url, figure out what selection was made, and pro grammatically change the control's values. this way, when the user refreshes the page, the url will contain all of his selections.
got it?
Instead of document.write you could setup an element used specifically to hold the output value much like you do currently with the input element.
In place of the current input element used to output the result..
<span id="calculationResult"></span>
Then to populate that value and avoid reloading the page at all so that your fields maintain current values..
document.getElementById("calculationResult").innerHTML = result;
if you need to append you can always just create text nodes and append to the element which would be preferred anyway.
In order to keep text boxes' content as is, set the button as type="button" and call the calculate function and document.write in onclick. No reload, no mess.