Java script for change the element properties and find element by id and class
Ruby on rails partial add more link
Once the partial load it 'll change the file field id as count
and set the ratio button propertie as disabled and id is chaged
Because of empty file not as profile picture
After file field change the radio button as also enabled
<script type="text/javascript">
var count = 1;
$(document).ready(function(){
var id_array = ["0"];
var current_element = document.getElementById("file_field");
var current_radio_element = document.getElementById("profile_image_profile");
var element_array = document.getElementsByClassName("after_load");
if (element_array.length != 0) {
for (var i = 0; i < element_array.length; i++) {
id_array.push(element_array[i].id);
}
current_element.id = Math.max.apply( Math, id_array ) + 1 ;
current_radio_element.id = (Math.max.apply( Math, id_array ) + 1)+ "_radio" ;
current_element.setAttribute('class',"after_load");
}else{
current_element.id = count;
current_radio_element.id = count + "_radio";
current_element.setAttribute('class',"after_load");
}
current_radio_element.disabled = "true";
function sortNumber(a, b)
{
return a - b;
}
});
function radio_property(filefield) // set radio button value and enable
{
var radio_element = document.getElementById(filefield.id + "_radio");
radio_element.value = filefield.value;
radio_element.disabled = "";
}
</script>
...............
var current_element = document.getElementById("file_field"); // in this line the file field element is find by the getElementById function...
var element_array = document.getElementsByClassName("after_load");
// find the element using class name
Math.max.apply( Math, id_array )
//Math function going to find maximum value in numeric array...
current_element.setAttribute('class',"after_load");
//SetAttiribute function set the class name as "after_load" for the current_element..
current_radio_element.disabled = "true";
//disable the radio button
function sortNumber(a, b)
{
return a - b;
}
//This function used to sort the array....
radio_element.value = filefield.value;
// radio button value is change when the file field is onchange...
with file field content...
Enabled Radio button with file field value
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment