Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

i dont want a select box to show when printing, just the selected valu 1

Status
Not open for further replies.

andycape

Programmer
Aug 22, 2003
177
ZA
I want to have a select box where a user can choose a selection, and then print the form and the selection must appear on the form when printed, not the select box.
I am using the code below, but how do i pass the selected value to the variable "store" to print ?
thanx.


<span class=&quot;Print&quot;>
<tr>
<td Branch : b><%= store %></b></td>
</tr>
</span>

<span class=&quot;noPrint&quot;>
<tr>
<td Branch :<b>
<select name=&quot;Company&quot;>
<!--#include virtual=&quot;/common/database.inc&quot;--><%
Set RSC = MyClientsConn.Execute(&quot;SELECT * FROM Stores&quot;)
IF not RSC.EOF then
RSC.MoveFirst
do while Not RSC.eof
%>
<option value=&quot;<%=RSC(&quot;Code&quot;)%>&quot;><%=RSC(&quot;Store&quot;)%></option>
<% End If
RSC.MoveNext
LOOP
END IF%>
</select>
</b></td>
</tr>
</span>
 
O.K iread ur other post and thought something else. there is a way to handle this and that is DOM

after u write ur select box add this code (not inside noPrint class).

<div id=&quot;sel&quot;>
</div>

<input type=&quot;button&quot; onclick=&quot;PrintWin()&quot;>

<script>
function PrintWin()
{
document.getElementById(&quot;sel&quot;).innerHTML=document.FormName.Company.options[document.FormName.Company.selectedIndex].value

window.print()
}
</script>

does this help?

Known is handfull, Unknown is worldfull
 
You could also do this on the server. In your script where you are looping through the options simply have another if statement. When you reach the value you want to match change the <option value=&quot;<%=RSC(&quot;Code&quot;)%>&quot;><%=RSC(&quot;Store&quot;)%></option> code to <option value=&quot;<%=RSC(&quot;Code&quot;)%>&quot;><%=RSC(&quot;Store&quot;)% selected></option>



MrBelfry
 
andycape:
just one more idea as soon as the prining happens if u want that extra text to disappear then:
Code:
function PrintWin()
{
 document.getElementById(&quot;sel&quot;).innerHTML=document.FormName.Company.options[document.FormName.Company.selectedIndex].value

 window.print()

 document.getElementById(&quot;sel&quot;).innerHTML=&quot;&quot;
}

Note: I havent checked this before...

Known is handfull, Unknown is worldfull
 
thats actually a good point, what you say does work, but is it possible to bring up the select box again using a similar method ???
 
what do u mean by the select box? it is always visible aint it? or did u put that also in the div tag? please dont put the select box in the div tag...

Known is handfull, Unknown is worldfull
 
ahhh, i see what you mean, i was making the select box dissapear, and get replaced my the test value.

excellent, i can fix that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top