0

hii....
this is my first thread..hope i return satisfied..
i am a newbie in asp ,net...i want urgent help...
the following snippet i am going to present was copied from some where though it works perfectly fine...i jst want to change its functionality a bit..............its basically a drop down box...i want that whatever number i choose ie 1 2 3 ...i get 100,200,300 resp in my label11.text...the code i got uses return alert ...instead of return alert i want the value to be displayed in drop down box....the foll code is

<select id="dropdown" onchange="storeVal(this,'hiddenVal');">
<option value="default">--Select no. of seats--</option>
<option value="A">1</option>
<option value="B">2</option>
<option value="C">3</option>
<option value="D">4</option>
</select>

<input type="hidden" id="hiddenVal" />


<script type="text/javascript">

function storeVal(selectObj,id)
{


    var hiddenObj = document.getElementById(id);
    var optionArr = selectObj.getElementsByTagName("option");

    if (selectObj.value == "default") return false;

    for (i=1; i<=optionArr.length; i++)
    {
        if (selectObj.value == optionArr[i].value)
        {
            hiddenObj.value = i;

 return alert('Your total cost is Rs.' +100* i + '');

            }
        }

    }


</script>

hope to get early answers...

Edited by pyTony: fixed formatting

2
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by arc64
0

insert text box in form and create one variable of type string just giving idea

replace

return alert('Your total cost is Rs.' +100* i + '');

by

int  value = 100 * i;
            string str =Convert.ToString  ("Your total cost is Rs" + value );
            textBox1.Text = value.ToString();

tested by me
if ok with u dont forgate to click on solved

0

hey thnx 4 ur concern nd help...tried the code bt there is no effect on text box...it remains unchanged....is dis coz i m tryin dis code in html page nd nt in .cs page...pls helppp.............

0

just do googling how to use this code in html cose yet i dont work on html so try on ur please sorry for this time but logic is working so apply same logic ok

0

kk...thnx..bt wen im tryin di in c#..den it is giving error in

function storeVal(selectObj,id)...dis line...jst temme wher e u wrote d code...bt thnx nyways...4 ur help..

0

actualy dear m quite busy with work so right now dont have bit time to understand and solve ur problem sorry for that but try after finnishing work ok u also try your own and never use small words like" 4 ur dis " in this comunity becose admin will give you warning and dwduct your Raputation Point k so take care of that

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.