UPDATE
How is what I am asking, different from this example from jQuery
<script>
$( "div" ).click(function() {
var color = $( this ).css( "background-color" );
$( "#result" ).html( "That div is <span style='color:" +
color + ";'>" + color + "</span>." );
});
</script>
I am building this parameter based search engine that when a person selects a value from a specific select box, that value is added to a text input which can be modified directly eg. typing.
I have that part, what I'm trying to solve is how to remove repeats eg. if someone decides to change the value that they had selected for one select input that they had already selected, the value should replace the old value.
I am trying to solve this by building a variable / instance of a list which ads on as more select fields are selected eg. have value.
What I tried to apply is this
So I have a select input like this -side note- I realize that onchange and onclick may be redundant if I can accomplish all in one but it's nice to know I have the option to use more than one.
<select name="name of select" id="id of select" onchange="changeFunc(value);" onclick="check();">
So I have this to create a variable / instance to append select values to
function addParameters(){
// build selected options list
function currentOptionsSelected(){
this.value = "";
}
var cOS = new currentOptionsSelected();
function updateCOS(fnc){
}
}
That is the plan once I get this to work
function check(){
var nameOfSelectBox = $(this).attr("name");
$( "select" ).click(function() {
var nameOfSelectBox = $( this ).attr("name");
var nameOfSelectBox = $('[name=" "]');
alert(nameOfSelectBox);
});
var nameOfSelectBox = $("select").attr("name");
alert(nameOfSelectBox);
updateCOS(fnc);
}
As you can see I was trying different methods.
So, I check with str.match() if the select name already has been used eg. selected and then I update the value
If there is a better way, suggestions are welcome.
Thank you
Aucun commentaire:
Enregistrer un commentaire