PDA

View Full Version : checkbox to response.write


needhelp26
10-05-2004, 10:06 PM
Hi,

I would like to know how to add checkboxs to response.write:

For example:


Response.write"<center><table border=""0"" width='50%'>"
Response.write"<tr bgcolor=silver>"
Response.write"<td>" & RS ("Field1") & "</td>"
Response.write"<td>" & RS ("Fiedl2") & "</td>"
Response.write"</tr>"
Response.write"</table>"


I want to add checkbox to each row and when click on it, should take to form submit.

In order to do form submit, I have to concatenate field1 and field2 together as one checkbox name. How do I do that?

Thanks.

glenngv
10-06-2004, 04:04 AM
Response.write "<input type=""checkbox"" name=""" & RS("Field1") & RS ("Field2") & """ value=""1"" onclick=""this.form.submit()"">"

needhelp26
10-06-2004, 04:42 AM
Thankyou. Instead of giving the onclick=""this.form.submit()"" inside the <input type>, can I create a submit button and add the onclick Event to that submit button?

glenngv
10-06-2004, 06:57 AM
Then use submit button and not checkbox.

Response.write "<input type=""submit"" name=""" & RS("Field1") & RS ("Field2") & """ value=""Submit"" />"

needhelp26
10-06-2004, 07:40 PM
Sounds good, but where will it submit in the form. Why can't I use the onclick event for submit. I also need the checkbox there because when I click the checkbox, and submit, I am sending that data to a textbox field in a form. That's why I wanted to have a variable for the checkbox name and asked how to do a concatenataion such as :

below code will be included in the following page, ie

Response.write"<center><table border=""0"" width='50%'>"
Response.write"<tr bgcolor=silver>
Response.write"<td><input type=checkbox name=chkvalue value="chkvalue"></td>"
Response.write"<td>" & RS ("Field1") & "</td>"
Response.write"<td>" & RS ("Field2") & "</td>"
Response.write"</tr>"
Response.write"</table>"


chkvalue= " & RS("field1") & RS ("field2")& "

Then do a request.form in the form such as:

chkvalue = Request.Form("chkvalue")

For the textbox value in the form such as:

' I am doing a search data value for the following field.
<input type=textbox name=chkvalue value="<%Response.write(chkvalue)%>">

And for the submit, use a onclick event to submit to the form.

Please let me know if the above codes will do what I just wanted to do.

Is there really a submit like you mentioned? I don't understand. If possible, can you explain?

glenngv
10-07-2004, 06:09 AM
Your explanation is not clear to me or is it just me? Can you explain it again?

needhelp26
10-07-2004, 03:12 PM
okay. I have form named as form1. In that I have textbox named as chkvalue.

form goes like this:

form1.asp


chkvalue = Request.Form("chkvalue")

<form method=post action=blah blah name=form1>
<table>
<!-- multiple textboxes are displayed..this is a retrieval page....but the textbox below is empty box, we have to get the value from the search page-->
<tr>
<td>Textbox:</td>
<td><input type="text" name="chkvalue" value="<%Response.write(chkvalue)%>"><br />
<!-- user clicks on the search page, do a search, find a result, checkmark the row which the user selects, submits to this form-->
<a href="search.asp" target="_blank" style=text-decoration:none>Search for value</a></td>
</tr>
</table>
<input type=submit name=submit value=submit>
</form>


now the seach page:


<form method=post action=form1.asp>
chkvalue= " & RS("field1") & RS ("field2")& "
Response.write"<center><table border=""0"" width='50%'>"
Response.write"<tr bgcolor=silver>
Response.write"<td><input type=checkbox name=chkvalue value="chkvalue"></td>"Response.write"<td>" & RS ("Field1") & "</td>"
Response.write"<td>" & RS ("Field2") & "</td>"
Response.write"</tr>"
Response.write"</table>"
<br />

<!--can I use an onclick event here-->
<input type=submit name=submit value=submit>


Hope it is understandable now.

needhelp26
10-07-2004, 04:07 PM
sorry for entering two times...look this one, this is the latest.

okay. I have form named as form1. In that I have textbox named as chkvalue.

form goes like this:

form1.asp


chkvalue = Request.Form("chkvalue")

<form method=post action=blah blah name=form1>
<table>
<!-- multiple textboxes are displayed for input.....but the particular one will collect data from a search page-->
<tr>
<td>Textbox:</td>
<td><input type="text" name="chkvalue" value="<%Response.write(chkvalue)%>"><br />
<!-- user clicks on the search page, do a search, find a result, checkmark the row which the user selects, submits to this form-->
<a href="search.asp" target="_blank" style=text-decoration:none>Search for value</a></td>
</tr>
</table>
<input type=submit name=submit value=submit>
</form>


now the seach page:


<form method=post action=form1.asp>
chkvalue= " & RS("field1") & RS ("field2")& "
Response.write"<center><table border=""0"" width='50%'>"
Response.write"<tr bgcolor=silver>
Response.write"<td><input type=checkbox name=chkvalue value="chkvalue"></td>"Response.write"<td>" & RS ("Field1") & "</td>"
Response.write"<td>" & RS ("Field2") & "</td>"
Response.write"</tr>"
Response.write"</table>"
<br />

<!--can I use an onclick event here-->
<input type=submit name=submit value=submit>


Hope it is understandable now.

needhelp26
10-09-2004, 03:14 PM
Can someone please guide me on this little coding? thanks.

Paardekam.nl
10-09-2004, 05:38 PM
I don't understand your problem exactly, but when I looked at the code, I noticed:

<!--can I use an onclick event here-->
<input type=submit name=submit value=submit>

If you do NOT want a submit-button, (I don't know why not, but suppose you have a great reason for that ;)) then try:

<input type="Button" name="anyNameYouLike" value="TheTextOnTheButton" onClick="anyJavaScriptActionYouLike()">

Does this solve the problem?

glenngv
10-11-2004, 02:39 AM
I don't exactly understand what you were trying to do too. But do you want something like this?

<form method="post" action="form1.asp">
<%
chkvalue = RS("Field1") & RS ("Field2")
Response.write "<center><table border=""0"" width=""50%"">"
Response.write "<tr bgcolor=""silver"">"
Response.write "<td><input type=""checkbox name=""chkvalue"" value=""" & chkvalue & """ /></td>"
Response.write "<td>" & RS ("Field1") & "</td>"
Response.write "<td>" & RS ("Field2") & "</td>"
Response.write "</tr>"
Response.write "</table>"
%>
<input type="submit" name="btnSubmit" value="Submit" />

needhelp26
10-11-2004, 03:03 AM
<input type="Button" name="anyNameYouLike" value="TheTextOnTheButton" onClick="anyJavaScriptActionYouLike()">


...anyJavaScriptActionYouLike..so for the action, do I have to write a Function to call the action? or something like this:

<input type="Button" name="anyNameYouLike" value="TheTextOnTheButton" onClick="href-location:form1.asp"()"> ' form1.asp is the file name of the form


glenngv and Paardekam.nl, thankyou both for your responses. If you ask, if this what I am looking, may be or may be not. I have something in mind to implement but short of correct syntax and procedure, that is why I am here...I am hoping your responses will lead me to what I have in mind.

Paardekam.nl
10-11-2004, 09:12 PM
Well, if you just want to post the form-data to a .ASP-page which will process the fields of your form, then you could do something like this:

<FORM ACTION="form1.asp" METHOD="POST" NAME="FormName">
<INPUT TYPE="Text" NAME="Textfield1">
<INPUT TYPE="Submit" VALUE="Process data">
</FORM>
But that just is a regular form... You can also replace the Submit-button by this line:

<INPUT TYPE="Button" VALUE="Process data" onClick="document.FormName.submit()">

That does exactly the same... But I must admit that it doesn't get any clearer what the exact problem is that you have... I really have no clue! :confused:

needhelp26
10-12-2004, 01:20 AM
okay. thankyou. I don't know how well to explain. Well I will try again. I have an application form. Lets say this as form1.asp. Most of the information, the users enter by typing such as Name, Address, City, etc. But when it comes to a particular field, they have an option to search from a different database, get the result, when they checkmark that row from the result page(field1 and field2), and submit, that information is preloaded in that particular field in form1.asp. This might look simple, but it seems too completed for me.

glenngv
10-12-2004, 03:15 AM
Since you open search.asp from form1.asp in a new window, you don't have to submit the search form. Just set the field in form1.asp from search.asp page.
search.asp:

<head>
<script type="text/javascript">
function doSelect(objChk){
var closeIt = true;
if (opener && !opener.closed && objChk){
if (objChk.checked){
opener.document.form1.chkvalue.value = objChk.value;
}
else {
alert("Please select the item.");
closeIt = false;
}
}
if (closeIt) window.close();
}
</script>
</head>
<body>
<form name="form1">
<%
chkvalue = RS("Field1") & RS ("Field2")
Response.write "<center><table border=""0"" width=""50%"">"
Response.write "<tr bgcolor=""silver"">"
Response.write "<td><input type=""checkbox name=""chkvalue"" value=""" & chkvalue & """ /></td>"
Response.write "<td>" & RS ("Field1") & "</td>"
Response.write "<td>" & RS ("Field2") & "</td>"
Response.write "</tr>"
Response.write "</table>"
%>
<input type="button" value="Select" onclick="doSelect(this.form.chkvalue)" />
<input type="button" value="Cancel" onclick="window.close()" />

form1.asp:

<form method="post" action="blah blah" name="form1">
<table>
<!-- multiple textboxes are displayed for input.....but the particular one will collect data from a search page-->
<tr>
<td>Textbox:</td>
<td><input type="text" name="chkvalue" /><br />
<!-- user clicks on the search page, do a search, find a result, checkmark the row which the user selects, submits to this form-->
<a href="search.asp" target="_blank" style="text-decoration:none">Search for value</a>
</td>
</tr>
</table>
<input type="submit" name="btnSubmit" value="Submit" />
</form>

The javascript code in the search page above assumes that the search result has 0 or 1 item only. Tell me if the search result may have multiple items and I'll fix the code.

Paardekam.nl
10-12-2004, 10:20 PM
Seems good to me. I think this is the solution you were looking for! :thumbsup:

needhelp26
10-13-2004, 03:55 AM
Yes, this is what I was looking for. Thanks.

I am getting an error and the error line:


chkvalue = RS("Field1") & RS ("Field2")


Error is: Type mismatch

I checked the spelling and every possible thing in my code, but not able to find out what may be the issue.

And another problem I have is, most of the codings are vbscript, if I include javascript, will it contradict?

Is there a way to do in vbscript instead of javascript?

needhelp26
10-17-2004, 03:04 AM
Hi,

I am still stuck with the error: Microsoft VBScript runtime error '800a000d'

Type mismatch.

And it points to:

chkvalue = RS("Field1") & RS ("Field2")

needhelp26
10-24-2004, 01:18 AM
Can you help with multiple item javascript code. I have three items. And also, not sure why I do have the type mismatch error.