Forums
This topic is locked
writing to a text file using radio buttons
Posted 29 Oct 2007 20:28:55
1
has voted
29 Oct 2007 20:28:55 Mary webmaster posted:
We are trying to develop code that writes to a text file using request.query string(donor) to bring in a member number and using two radio buttons that have values of Yes or No. So our end results in the text file should be: 123456789, NWe have code that is writing the member number(donor) to the text file before the submit button is clicked. We only want it to write to the text file once the submit button is clicked. Also, it is not reading the value of the radio buttons. We think we need to call a function from the submit button, but not sure how to do it. I can send the code if needed...
Mary
Replies
Replied 30 Oct 2007 12:06:00
30 Oct 2007 12:06:00 Lee Diggins replied:
Hi Mary
You need to run the code on submit of the form. Depending on the method you are using either POST or GET you need to wrap your text file creation code in an IF statement that checks if the form has been submitted:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Dim strValue, strMethod
If Request.Form("Submit" = "SubmitPost" Then
strValue = Request.Form("textfield"
strMethod = "POST"
ElseIf Request.QueryString("Submit" = "SubmitGet" Then
strValue = Request.QueryString("textfield"
strMethod = "GET"
Else
strValue = "NO VALUE"
strMethod = "NO FORM SUBMISSION"
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="form1" id="form1" method="post" action="">
<p><strong>Submit Using POST:</strong>
<input type="text" name="textfield" />
<input type="submit" name="Submit" value="SubmitPost" />
</p>
</form>
<form action="" method="get" name="form2" id="form2">
<strong>Submit Using GET:
<input type="text" name="textfield" />
<input type="submit" name="Submit" value="SubmitGet" />
</strong>
</form>
<p>You submitted the value <%= strValue %> using: <%= strMethod %></p>
</body>
</html>
If you can't get this to work, you might consider creating an addition page to handle the file creation and submit the form to that page.
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>
You need to run the code on submit of the form. Depending on the method you are using either POST or GET you need to wrap your text file creation code in an IF statement that checks if the form has been submitted:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Dim strValue, strMethod
If Request.Form("Submit" = "SubmitPost" Then
strValue = Request.Form("textfield"
strMethod = "POST"
ElseIf Request.QueryString("Submit" = "SubmitGet" Then
strValue = Request.QueryString("textfield"
strMethod = "GET"
Else
strValue = "NO VALUE"
strMethod = "NO FORM SUBMISSION"
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="form1" id="form1" method="post" action="">
<p><strong>Submit Using POST:</strong>
<input type="text" name="textfield" />
<input type="submit" name="Submit" value="SubmitPost" />
</p>
</form>
<form action="" method="get" name="form2" id="form2">
<strong>Submit Using GET:
<input type="text" name="textfield" />
<input type="submit" name="Submit" value="SubmitGet" />
</strong>
</form>
<p>You submitted the value <%= strValue %> using: <%= strMethod %></p>
</body>
</html>
If you can't get this to work, you might consider creating an addition page to handle the file creation and submit the form to that page.
Sharing Knowledge Saves Valuable Time!!!
~ ~ ~ ~ ~ ~
<b>Lee Diggins</b> - <i>DMXzone Manager</i>
<font size="1">[ Studio MX/MX2004 | ASP -> VBScript/PerlScript/JavaScript | SQL | CSS ]</font>