PDA

View Full Version : Pass filename to add as a new option value to droplist menu?


wanye
10-21-2002, 07:25 PM
hi, for example i have this piece of code as shown below :


<%
dim objdom
set objdom=server.CreateObject("Msxml2.domdocument")
dim filepath
dim filename
dim objelm
dim objPI
dim objPII
set objPI=objdom.createProcessingInstruction("xml","version=""1.0""")
objdom.appendChild objPI
set objPII=objdom.createProcessingInstruction("xml-stylesheet","type=""text/xsl""")
objdom.appendChild objPII

set objelm=objdom.createElement("content")

objdom.appendChild objelm

set objelm=objdom.createElement("title")

objdom.documentElement.appendChild objelm

set objelm=objdom.createElement("s-title")

objdom.documentElement.appendChild objelm

set objelm=objdom.createElement("flash")

objdom.documentElement.appendChild objelm



objdom.save "C:\flash.xml"

%>

<form action="flash.asp" method="post" >
<h3>Edit your Flash</h3>
<b>Title:<b><input type="text" id="Title" name="Title" style="width: 200px;"><br><br>
<b>Sub Title:<b><input type="text" id="Stitle" name="Stitle" style="width: 170px;"><br><br>
Insert Flash:<input type="file" id="swf" name="swf"><br><br>

Enter your filename: <input type="text" id="txtfilename" name="txtfilename" style="width: 180px;"><br><br>

<input type="submit" id="btnSub" name="btnSub" value="Submit" ><br>
</form>


how do i actually pass the filename that i input through the field as a new option value in a dropdown list menu whenever i click on the "submit btn"..?

is like when i put the 1st filename as xxx1.xml and click submit... it will be something like this

<form name="selection" method="post" action="xxx.asp">
<select name="xmlfield">
<option value="xxx1.xml" >xxx1.xml
</select>

then when put another filename call xxx2.xml, click submit it will become
....
<select name="xmlfield">
<option value="xxx1.xml" >xxx1.xml
<option value="xxx2.xml" >xxx2.xml
</select>

I need help on this badly....thks......

raf
10-22-2002, 09:17 AM
wanye,

displaying something in a dropdownlist isn't all that different then just displaying it as text.
when you submit the form to xxx.asp, you can read the value from that field and write it to another page.

Something like



<form name="selection" method="post" action="xxx.asp">
<select name="xmlfield">
<option value="<%response.write(request.form("txtfilename"))%>"><%response.write(request.form("txtfilename"))%>
</select>



Now, with this code, it goe's straight from the form to the dropdown list, buth this can get complicated if you want to add a new option to an existing list. I think you best write the info from the form (including the filename) to a database, were you have a value (an ID or another number-variable) for each option. On the same connection, you make a select to get all the options (filenames and ID) and that you then loop through the recordset and populate the dropdown.

example code for populationg dropdown:



<form action="ven_eigenschappen_soort.asp" target="body" id="FORM1" method="post" name="FORM1">
<b>Klik op de gewenste soort.</b>
<p><select id="select1" name="soorten" size="10" onclick="submit();">
<%

dim rsSoort
set rsSoort = server.CreateObject("adodb.recordset")

dim sql
sql="select nummer,naam from soorten where categorie=eencategorie"
sql=replace(sql,"eencategorie",request.form("categorie"))
rsSoort.Open sql, conGranIT

'populating the dropdown
do while rsSoort.EOF=false
Response.Write("<option value=" & rsSoort.Fields("nummer")& ">")
Response.Write(server.HTMLEncode(rsSoort.Fields("naam")) & "</option>")
'server.HTMLEncode takes care of filenames with weird caracters
rsSoort.MoveNext
loop



rsSoort.Close
set rsSoort=nothing


%>
</select>
</form>



Of coarse, there are still oter options, buth i think the databaseinsertion and then retrieving it in a recordset is the best way to go.

Hope this helps you further. If not : let us know.