<select id="pickone">
<option id='first_time_user'value ='First Time User'>First Time User</option>
<option id='frequent_flier'value ='Frequent Flier'>Frequent Flier</option>
<option id='buying_a_degree' value ='Buying a Degree'>Buying a Degree</option>
</select>
Im trying that when i click a submit button, I can add a certain element to each of those options. Does anyone know how?
I want to display an alert for option[0]
and for each option[1] and option[2], i want to multiply a total_cost feature by a percentage, 0.75 for option[1] and 0.5 for option[2]
Hm... When you submit, you change the session, thus any JavaScript (which is a client-side language) previous changes are gone (except if using cookies)
If you are dealing with a dataBase, probably it would be better to submit the page on itself, and use a server-side language, and probably a session variable, to do that.
Hm... When you submit, you change the session, thus any JavaScript (which is a client-side language) previous changes are gone (except if using cookies)
If you are dealing with a dataBase, probably it would be better to submit the page on itself, and use a server-side language, and probably a session variable, to do that.
Give us more details.
its client side, im choosing an option from the select box, which either adds an alert, or multiplies a total cost by a percentage (.75, 0.5) and places the new total in a form box.
if it was a radio button, the code would be:
if (document.form.radio.checked==true)
{
total_cost=total_cost*.75
}
im just unsure of how to chnage that statemnt so that it applies to a select box option
function dosomething(sel){
var ind=sel.selectedIndex;
if(ind==0){
alert('message here')
}
else if(ind==1){
// multiply that value with 0.75
}
else if(ind==2){
// multiply that value with 0.5
}
}
function dosomething(sel){
var ind=sel.selectedIndex;
if(ind==0){
alert('message here')
}
else if(ind==1){
// multiply that value with 0.75
}
else if(ind==2){
// multiply that value with 0.5
}
}
i already have a function i want it part of, calc(), so if i just change yours:
function dosomething(sel)
and
var ind=sel.selectedIndex
getting rid of teh function line, since i have one for teh overall function, and then would i change the sel in sel.selectedIndex, to calc?
or just leave it?
changing the name should not make any difference if it is changed in all the right places and doesn't clash with an existing name elsewhere.
If you post your current code it will be easier to figure out what is going on.
i figured it out, but it doesnt make sense to me
it was based upon an option in the drop list, and as long as it stayed on that option, and i kept pushing submit button, it would show up, but once i went to a different option and back to it, it would stop showing completely like i wanted
Bookmarks