Simple ASP help needed

Discussion in 'Web Design and Development' started by ghostchild, Jul 28, 2009.

  1. ghostchild macrumors 6502

    ghostchild

    Joined:
    Jun 17, 2007
    #1
    Hey guys so I have this code here... I want the output of the form to be in a text box (so I can use select all) and not just above the form. Can anyone help me?

    PHP:
    <%

    ink_type            request("ink_type") : if ink_type "" then ink_type "Toner"

    brand                    request("brand") & " "

    product_list    request("product_list"



    'response.write product_list

    '
    response.end

    if product_list <> "" then



        toner_keywords    
    request("toner_keywords"

        
    ink_keywords    request("ink_keywords"

        
    fax_keywords    request("fax_keywords"

        
    drum_keywords    request("drum_keywords"
        
        
    toners_keywords    request("toners_keywords"

        
    inks_keywords    request("inks_keywords"

        
    faxes_keywords    request("faxes_keywords"

        
    drums_keywords    request("drums_keywords"

            
    select case ink_type

                
    case "Toner":        arrKeywords split(request("toner_keywords"), vbcrlf)

                case 
    "Ink":            arrKeywords split(request("ink_keywords"), vbcrlf)

                case 
    "Fax":         arrKeywords split(request("fax_keywords"), vbcrlf)

                case 
    "Drum":         arrKeywords split(request("drum_keywords"), vbcrlf)

                case 
    "Toners":        arrKeywords split(request("toners_keywords"), vbcrlf)

                case 
    "Inks":        arrKeywords split(request("inks_keywords"), vbcrlf)

                case 
    "Faxes":         arrKeywords split(request("faxes_keywords"), vbcrlf)

                case 
    "Drums":         arrKeywords split(request("drums_keywords"), vbcrlf)

            
    end select



    if instr(1,product_list,vbcrlf) = 0 then product_list product_list vbcrlf



        
    if instr(1,product_list,vbcrlfthen 'multiple

            arrProduct_List = split(product_list, vbcrlf)



            for m = 0 to ubound(arrProduct_List)-1



                for i = 0 to ubound(arrKeywords)

                    if trim(brand) <> "" then 

                        str1 =  str1 & brand & arrProduct_List(m) & " " & arrKeywords(i) & "<br>"

                    else



                    end if

                    if trim(arrProduct_List(m)) <> "" then str2 = str2 & arrProduct_List(m) & " " & arrKeywords(i) & "<br>"    

                next

            next



        else ' 
    single 



            
    'for i = 0 to ubound(arrProduct_List)

            '        
    if trim(arrProduct_List(i)) <> "" then str2 str2 arrProduct_List(i) & " " arrKeywords(i) & "<br>"    

            'next

        end if



    else

        '
    strConnection "driver={MySQL};server=localhost;uid=toner;pwd=toner;database=monster_toner_db;option="

        'Set Conn = Server.CreateObject("ADODB.Connection") 

        '
    Set RS Server.CreateObject("ADODB.Recordset"

        
    'Conn.Open strConnection 



        toner_keywords = "toner"",""toners"",""toner cartridge"",""toner cartridges"",""printer cartridge"",""printer cartridges"",""laser toner"",""laser toners"",""cartridge"",""cartridges"",""printer toner"",""printer toners"

        ink_keywords = "cartridge"",""cartridges"",""ink"",""inks"",""ink cartridge"",""ink cartridges"",""inkjet"",""inkjets"",""inkjet cartridge"",""inkjet cartridges"",""printer cartridge"",""printer cartridges"",""printer ink"",""printer inks "

        fax_keywords = "fax film"",""fax films"",""fax ribbon"",""fax ribbons"",""fax ribbon cartridge"",""fax ribbon cartridges"",""ribbon"",""ribbons"",""film"",""films"

        drum_keywords = "drum printer"",""drum cartridge"",""drum unit"

        toners_keywords = "toner"",""drum cartridge"",""drum unit"",""toner cartridge"",""toner cartridges"",""printer cartridge"",""printer cartridges"",""laser toner"",""laser toners"",""cartridge"",""cartridges"",""printer toner"",""printer toners"

        inks_keywords = "cartridge"",""inks"",""ink cartridge"",""ink cartridges"",""inkjet"",""inkjets"",""inkjet cartridge"",""inkjet cartridges"",""printer cartridge"",""printer cartridges"",""printer ink"",""printer inks "

        faxes_keywords = "fax film"",""fax ribbons"",""fax ribbon cartridge"",""fax ribbon cartridges"",""ribbon"",""ribbons"",""film"",""films"

        drums_keywords = "drum printer"",""drum cartridge"",""drum unit"



    end if



    response.write str2 & "<br><br>"

    response.write str1 & "<br>"

    %>

    <basefont face="arial" size=1>

    <form action="" method=post>

    <table cellspacing=10 cellpadding=10><tr><td valign=top>

    <br>

    <input type=radio value="Toner" <%if ink_type = "Toner" then response.write "checked" %> name="ink_type"><b>1. Toner</b>  

    <input type=radio value="Ink" <%if ink_type = "Ink" then response.write "checked" %> name="ink_type"><b>2. Ink</b>   

    <input type=radio value="Fax" <%if ink_type = "Fax" then response.write "checked" %> name="ink_type"><b>3. Fax</b>  

    <input type=radio value="Drum" <%if ink_type = "Drum" then response.write "checked" %> name="ink_type"><b>4. Drum</b>
    <br>
    <input type=radio value="Toners" <%if ink_type = "Toners" then response.write "checked" %> name="ink_type"><b>5. Toners</b>  

    <input type=radio value="Inks" <%if ink_type = "Inks" then response.write "checked" %> name="ink_type"><b>6. Inks</b>   

    <input type=radio value="Faxes" <%if ink_type = "Faxes" then response.write "checked" %> name="ink_type"><b>7. Faxes</b>  

    <input type=radio value="Drums" <%if ink_type = "Drums" then response.write "checked" %> name="ink_type"><b>8. Drums</b>
    <br><br>

    Brand: <input type=text value="<%=trim(brand)%>" name="brand" size=20 >

    <br>

    <textarea name="product_list" cols=50 rows=10><%=product_list%></textarea><br>

    <input type=submit value=submit>

    </td><td valign=top>

    <br> <br>

    <b>1. Toner keywords:</b><br> <textarea name="toner_keywords" cols=50 rows=10><%=replace(toner_keywords,""",""", vbcrlf)%></textarea><br><br>

    <b>2. Ink keywords: </b><br><textarea name="ink_keywords" cols=50 rows=10><%=replace(ink_keywords,""",""", vbcrlf)%></textarea><br><br>

    <b>3. Fax keywords: </b><br><textarea name="fax_keywords" cols=50 rows=10><%=replace(fax_keywords,""",""", vbcrlf)%></textarea><br><br>

    <b>4. Drum keywords: </b><br><textarea name="drum_keywords" cols=50 rows=10><%=replace(drum_keywords,""",""", vbcrlf)%></textarea><br><br>

    <b>5. Toners keywords:</b><br> <textarea name="toners_keywords" cols=50 rows=10><%=replace(toners_keywords,""",""", vbcrlf)%></textarea><br><br>

    <b>6. Inks keywords: </b><br><textarea name="inks_keywords" cols=50 rows=10><%=replace(inks_keywords,""",""", vbcrlf)%></textarea><br><br>

    <b>7. Faxes keywords: </b><br><textarea name="faxes_keywords" cols=50 rows=10><%=replace(faxes_keywords,""",""", vbcrlf)%></textarea><br><br>

    <b>8. Drums keywords: </b><br><textarea name="drums_keywords" cols=50 rows=10><%=replace(drums_keywords,""",""", vbcrlf)%></textarea><br><br>

    </td></tr>

    </table>

    </form>
    Thanks.
     
  2. memco macrumors 6502

    Joined:
    May 1, 2008
    #2
    Try this and let me know if that's what you're after. I changed the lines with response.write str1 and str2 so that they are surrounded by textareas. You can change the textarea tags there to add more rows and cols as needed. Also, I added a vbcrlf to the end of str1 and str2 so that they display one per line.

    PHP:
    <% 

    ink_type            request("ink_type") : if ink_type "" then ink_type "Toner" 

    brand                    request("brand") & " " 

    product_list    request("product_list")  



    'response.write product_list 

    '
    response.end 

    if product_list <> "" then 



        toner_keywords    
    request("toner_keywords")  

        
    ink_keywords    request("ink_keywords")  

        
    fax_keywords    request("fax_keywords")  

        
    drum_keywords    request("drum_keywords")  
         
        
    toners_keywords    request("toners_keywords")  

        
    inks_keywords    request("inks_keywords")  

        
    faxes_keywords    request("faxes_keywords")  

        
    drums_keywords    request("drums_keywords")  

            
    select case ink_type 

                
    case "Toner":        arrKeywords split(request("toner_keywords"), vbcrlf

                case 
    "Ink":            arrKeywords split(request("ink_keywords"), vbcrlf

                case 
    "Fax":         arrKeywords split(request("fax_keywords"), vbcrlf

                case 
    "Drum":         arrKeywords split(request("drum_keywords"), vbcrlf

                case 
    "Toners":        arrKeywords split(request("toners_keywords"), vbcrlf

                case 
    "Inks":        arrKeywords split(request("inks_keywords"), vbcrlf

                case 
    "Faxes":         arrKeywords split(request("faxes_keywords"), vbcrlf

                case 
    "Drums":         arrKeywords split(request("drums_keywords"), vbcrlf

            
    end select 



    if instr(1,product_list,vbcrlf) = 0 then product_list product_list vbcrlf 



        
    if instr(1,product_list,vbcrlfthen 'multiple 

            arrProduct_List = split(product_list, vbcrlf) 



            for m = 0 to ubound(arrProduct_List)-1 



                for i = 0 to ubound(arrKeywords) 

                    if trim(brand) <> "" then  

                        str1 =  str1 & brand & arrProduct_List(m) & " " & arrKeywords(i) & vbcrlf 

                    else 



                    end if 

                    if trim(arrProduct_List(m)) <> "" then str2 = str2 & arrProduct_List(m) & " " & arrKeywords(i) & vbcrlf   

                next 

            next 



        else ' 
    single  



            
    'for i = 0 to ubound(arrProduct_List) 

            '        
    if trim(arrProduct_List(i)) <> "" then str2 str2 arrProduct_List(i) & " " arrKeywords(i) & "<br>"     

            'next 

        end if 



    else 

        '
    strConnection "driver={MySQL};server=localhost;uid=toner;pwd=toner;database=monster_toner_db;option=" 

        'Set Conn = Server.CreateObject("ADODB.Connection")  

        '
    Set RS Server.CreateObject("ADODB.Recordset")  

        
    'Conn.Open strConnection  



        toner_keywords = "toner"",""toners"",""toner cartridge"",""toner cartridges"",""printer cartridge"",""printer cartridges"",""laser toner"",""laser toners"",""cartridge"",""cartridges"",""printer toner"",""printer toners" 

        ink_keywords = "cartridge"",""cartridges"",""ink"",""inks"",""ink cartridge"",""ink cartridges"",""inkjet"",""inkjets"",""inkjet cartridge"",""inkjet cartridges"",""printer cartridge"",""printer cartridges"",""printer ink"",""printer inks " 

        fax_keywords = "fax film"",""fax films"",""fax ribbon"",""fax ribbons"",""fax ribbon cartridge"",""fax ribbon cartridges"",""ribbon"",""ribbons"",""film"",""films" 

        drum_keywords = "drum printer"",""drum cartridge"",""drum unit" 

        toners_keywords = "toner"",""drum cartridge"",""drum unit"",""toner cartridge"",""toner cartridges"",""printer cartridge"",""printer cartridges"",""laser toner"",""laser toners"",""cartridge"",""cartridges"",""printer toner"",""printer toners" 

        inks_keywords = "cartridge"",""inks"",""ink cartridge"",""ink cartridges"",""inkjet"",""inkjets"",""inkjet cartridge"",""inkjet cartridges"",""printer cartridge"",""printer cartridges"",""printer ink"",""printer inks " 

        faxes_keywords = "fax film"",""fax ribbons"",""fax ribbon cartridge"",""fax ribbon cartridges"",""ribbon"",""ribbons"",""film"",""films" 

        drums_keywords = "drum printer"",""drum cartridge"",""drum unit" 



    end if 



    response.write "<textarea>" & str2 & "</textarea>" 

    response.write "<textarea>" & str1 & "</textarea>" 

    %> 

    <basefont face="arial" size=1> 

    <form action="" method=post> 

    <table cellspacing=10 cellpadding=10><tr><td valign=top> 

    <br> 

    <input type=radio value="Toner" <%if ink_type = "Toner" then response.write "checked" %> name="ink_type"><b>1. Toner</b>   

    <input type=radio value="Ink" <%if ink_type = "Ink" then response.write "checked" %> name="ink_type"><b>2. Ink</b>    

    <input type=radio value="Fax" <%if ink_type = "Fax" then response.write "checked" %> name="ink_type"><b>3. Fax</b>   

    <input type=radio value="Drum" <%if ink_type = "Drum" then response.write "checked" %> name="ink_type"><b>4. Drum</b> 
    <br> 
    <input type=radio value="Toners" <%if ink_type = "Toners" then response.write "checked" %> name="ink_type"><b>5. Toners</b>   

    <input type=radio value="Inks" <%if ink_type = "Inks" then response.write "checked" %> name="ink_type"><b>6. Inks</b>    

    <input type=radio value="Faxes" <%if ink_type = "Faxes" then response.write "checked" %> name="ink_type"><b>7. Faxes</b>   

    <input type=radio value="Drums" <%if ink_type = "Drums" then response.write "checked" %> name="ink_type"><b>8. Drums</b> 
    <br><br> 

    Brand: <input type=text value="<%=trim(brand)%>" name="brand" size=20 > 

    <br> 

    <textarea name="product_list" cols=50 rows=10><%=product_list%></textarea><br> 

    <input type=submit value=submit> 

    </td><td valign=top> 

    <br> <br> 

    <b>1. Toner keywords:</b><br> <textarea name="toner_keywords" cols=50 rows=10><%=replace(toner_keywords,""",""", vbcrlf)%></textarea><br><br> 

    <b>2. Ink keywords: </b><br><textarea name="ink_keywords" cols=50 rows=10><%=replace(ink_keywords,""",""", vbcrlf)%></textarea><br><br> 

    <b>3. Fax keywords: </b><br><textarea name="fax_keywords" cols=50 rows=10><%=replace(fax_keywords,""",""", vbcrlf)%></textarea><br><br> 

    <b>4. Drum keywords: </b><br><textarea name="drum_keywords" cols=50 rows=10><%=replace(drum_keywords,""",""", vbcrlf)%></textarea><br><br> 

    <b>5. Toners keywords:</b><br> <textarea name="toners_keywords" cols=50 rows=10><%=replace(toners_keywords,""",""", vbcrlf)%></textarea><br><br> 

    <b>6. Inks keywords: </b><br><textarea name="inks_keywords" cols=50 rows=10><%=replace(inks_keywords,""",""", vbcrlf)%></textarea><br><br> 

    <b>7. Faxes keywords: </b><br><textarea name="faxes_keywords" cols=50 rows=10><%=replace(faxes_keywords,""",""", vbcrlf)%></textarea><br><br> 

    <b>8. Drums keywords: </b><br><textarea name="drums_keywords" cols=50 rows=10><%=replace(drums_keywords,""",""", vbcrlf)%></textarea><br><br> 

    </td></tr> 

    </table> 

    </form>  
    <body>
    </body>
    </html>
     
  3. ghostchild thread starter macrumors 6502

    ghostchild

    Joined:
    Jun 17, 2007
    #3
    Hey thanks! Is there anyway to combine the output to just one text box instead of the two?
     
  4. memco macrumors 6502

    Joined:
    May 1, 2008
    #4
    Yup. Change these lines:

    PHP:
    response.write "<textarea>" str2 "</textarea>"  

    response.write "<textarea>" str1 "</textarea>"  
    to this one line:
    PHP:
    response.write "<textarea>" str2 str1 "</textarea>"  
     
  5. ghostchild thread starter macrumors 6502

    ghostchild

    Joined:
    Jun 17, 2007
    #5
    Thank you so much! Now is there anyway i can add a copy all or select all button for the output box?
     

Share This Page