/    Sign up×
Community /Pin to ProfileBookmark

Select dropdown list without submit a form?

[B]Select dropdown list without submit a form?[/B]
I have many drop down list in a form. I use a Onchange event that uses the form name and is added to the select tag. When I select a choice from the list, the selected
option will be submitted to a form handler when a selection is made
automatically and its will display data in text box also. But it’s use submit a form, got any idea onchange a drop down list without submit a form?

function combo_onchange() {
frmSelect.submit();
}

<body>
<form name=”frmSelect” method=”Post”></form>
</body>

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 01.2005 — Why not just remove the [b]frmSelect.submit()[/b] from the process? Perhaps I don't understand exactly what you're asking. Please explain further. Thanks.
Copy linkTweet thisAlerts:
@fyanymauthorApr 01.2005 — i use this frmSelect.submit function to call the vb script to display the data in the textbox when i select the dropdown list...

//here is java script function

function combo_onchange() {

frmSelect.submit();

//call vb script when onchange (submit form)

<%

dim name

dim acct

dim a,x

dim strSQL

acct=Request.Form("acct")

x = 0

set con2=server.CreateObject("ADODB.Connection")

set rs2=server.CreateObject("ADODB.Recordset")

cn2 = "Driver={MySQL ODBC 3.51 Driver};server=localhost;uid=root;database=invdata"

strSQL2="SELECT * FROM masfile WHERE ctype='AS' AND ccode='" & acct & "'"

rs2.open strSQL2, cn2

con2.open cn2


set a = con2.Execute(strSQL2)

If a.BOF = TRUE THEN

x= 0

else

x = 1

End if

If x= 1 then

newname = rs2("cdesp")

newtel = rs2("ctel")

End if

rs2.close

set rs2 = nothing

set con2 = nothing

%>


<BODY>

<form name="frmSelect" method="Post">

//dropdown list

<select id=acct language= javascript onChange="combo_onchange();" >

<option value="" selected>Select acct. No</option>

<%

rs.open "Select * FROM masfile where ctype='AS' order by ccode",con,3,2

do while not rs.EOF

Request.Form("acct") = rs("ccode") then

Response.Write "<option value='" &rs("ccode")& "'selected>" & rs("ccode")& "</Option>"

rs.movenext

else

Response.Write "<option value='" &rs("ccode")& "'>" & rs("ccode" & "</Option>"

rs.MoveNext

end if

loop

rs.Close

%>

</select>

</FROM>

</BODY>

GOT ANY IDEA TO ONCHANGE A DROPDOWN LIST, WITHOUT REFRESH/ SUBMIT A FROM?
Copy linkTweet thisAlerts:
@phpnoviceApr 01.2005 — Are you saying that you want the drop-down list to submit the form the first time but, after that, you want the drop-down list to NOT submit the form anymore?

If that is what you want, then add a hidden field to the form that controls whether the drop-down list submits the form or not. When the page is refreshed, by your ASP/VBScript function, it can change the value of this hidden field so that your drop-down list no longer submits the form.

For that matter, your ASP/VBScript function can completely remove the [b]onchange[/b] event from the drop-down list when the event is no longer needed. ?
Copy linkTweet thisAlerts:
@fyanymauthorApr 02.2005 — I meant i have two dropdown list "id" and "acct"

when i select "id", it display data like:

id: a01

name: alice

when i select 2nd dropdown list "acct", it will display

acct: 01

email:[email protected]

but i got a textbox name "comment", its a input type = "text",

the data i input will lost/ disapear everytime i click the dropdown list id or acct... ?


//when i select dropdown list, it call this function

function combo_onchange() {

frmSelect.submit();

//call vb script when onchange (submit form)

<%

id =Request.Form("id")

x = 0

.

.

.

newname = rs("name")


rs.close

set rs = nothing

set con = nothing

%>


<BODY>

<form name="frmSelect" method="Post">

//dropdown list

<select id=id language= javascript onChange="combo_onchange();" >

<option value="" selected>Select id </option>

.

.

.

</select>

</FROM>

</BODY>

do u know what i meant?
Copy linkTweet thisAlerts:
@phpnoviceApr 02.2005 — OK, are you asking how to retain data typed into a text box when the form is submitted? ...or, are you asking how you can retrieve data from the server-side without submitting the form?
×

Success!

Help @fyanym spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...