Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Dynamic radio Button

  • 30-11-2006 10:59am
    #1
    Registered Users, Registered Users 2 Posts: 224 ✭✭


    :confused: Hi,

    having a few problems trying to get this script working...any help would be appreciated. This is what i have done. Basically if the user has filled in a field on a db, they will be aloud click a radio otherwise "N/A" will appear.

    <%
    Dim strChkBox
    Dim vChkBox
    vChkBox=false
    If recordset1.Fields("FreightQuote").Value <> "" or NOT isnull(recordset1.Fields("FreightQuote").Value) Then
    vChkBox=true
    End If
    If vChkBox=false then
    strChkBox= Response.write "N/A"
    Else
    strChkBox=<input type="checkbox" name="chkbox" id="chkbox" value="<%=Recordset1.Fields.Item("CartID").Value%>">
    End If
    %>

    <input type="checkbox" name="chkbox" id="chkbox" value="<%strChkBox%>"></div>


Comments

  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    Could be wrong, it's been a while :). It looks like you trying to write N/A to the Response but you also trying to assign Response.Write to a variable. I've commented out the original line of code and put mine in. The changes are in bold.
    <%
    Dim strChkBox
    Dim vChkBox
    vChkBox=false
    	If recordset1.Fields("FreightQuote").Value <> "" or  NOT isnull(recordset1.Fields("FreightQuote").Value) Then
    		vChkBox=true
    		End If
    	If vChkBox=false then
    		'//strChkBox= Response.write "N/A" 
                    [b]Response.write "N/A"[/b]
    	Else
    		strChkBox=<input type="checkbox" name="chkbox" id="chkbox" value="<%=Recordset1.Fields.Item("CartID").Value%>">
    	End If
    %>
    				  
    <input type="checkbox" name="chkbox" id="chkbox" value="<%strChkBox%>"></div>
    


  • Registered Users, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    Thats cool. Cheers for that Evil Phil...Seems to have fixed that line but im getting a new error from the next line...


    Microsoft VBScript compilation (0x800A03EA)
    Syntax error
    checkbox.asp, line 349, column 9
    strChkBox=<input type="checkbox" name="chkbox" id="chkbox" value="<%=Recordset1.Fields.Item("CartID").Value
    ^

    Any ideas :confused:


  • Moderators, Society & Culture Moderators Posts: 9,689 Mod ✭✭✭✭stevenmu


    You have code delimiters ( <% and %> ) within your code. Basically an asp file contains a mix of regular html and vbscript code, you put vbscript code in between the start code delimter <% and the end code delimter %> to show the difference between them. In you case you've got some code between a <% and a %> but you've got another <% and %> that you don't need on the line with the error.

    When you take them out, you're going to get another error because in that line you're trying to assign a string to strChkBox but you don't have quotes around it, you'll need to put quotes around it, and because your string needs to have quotes in it aswell, you'll need to put double quotes in for them which should give you something like
    strChkBox="<input type=""checkbox"" name=""chkbox"" id=""chkbox"" value=""" + Recordset1.Fields.Item("CartID").Value + """>"
    

    You'll then need to write that string out to response. You also seem to have the same checkbox in below in the HTML part of the file (outside the code delimiters), you'll probably want to take that out too or you'll end up with the same checkbox twice. :)


  • Registered Users, Registered Users 2 Posts: 4,475 ✭✭✭corblimey


    <%
    Dim strChkBox
    Dim vChkBox
    vChkBox=false
    	If recordset1.Fields("FreightQuote").Value <> "" or  NOT isnull(recordset1.Fields("FreightQuote").Value) Then
    		vChkBox=true
    	End If
    
    	If vChkBox=false then
    		strChkBox= "N/A" 
    	Else
    		strChkBox="<input type=""checkbox"" name=""chkbox"" id=""chkbox"" value=""" + Recordset1.Fields.Item("CartID").Value + """>"
    	End If
    %>
    				  
    <%=strChkBox%></div>
    


  • Registered Users, Registered Users 2 Posts: 224 ✭✭The Mighty Dubs


    Thanks for that guys..thats working nicely


  • Advertisement
Advertisement