473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How do I set a cookie with a radio button?

I have a php driven web app and I want the user to be able to select if they
wmnt to see the next page in html or PDF format with a radio button.
I wrote a funtion:

<script language="javascript" type="text/javascript">
<!--
function writeRadio() {
var a;
a = document.form1.PDF.value;
document.cookie = 'showHTML=' + a + '; expires=Thu, 2 Aug 2008 20:47:11 UTC;
'
//window.location = "http://testord.pdfkqs.local.samplelookupshow.php"
}
//-->
</script>

Then implemet it in the button:

<td>PDF<input type="radio" name="PDF" value="PDF" onclick.writeRadio()
checked>or HTML
<input type="radio" name="PDF" value="HTML" onclick.writeRadio() ></td>

but I never see the cookie set with php. What am I doing wrong?
Apr 17 '07 #1
2 5030
Lee
Willie said:
>
I have a php driven web app and I want the user to be able to select if they
wmnt to see the next page in html or PDF format with a radio button.
I wrote a funtion:

<script language="javascript" type="text/javascript">
<!--
function writeRadio() {
var a;
a = document.form1.PDF.value;
document.cookie = 'showHTML=' + a + '; expires=Thu, 2 Aug 2008 20:47:11 UTC;
'
//window.location = "http://testord.pdfkqs.local.samplelookupshow.php"
}
//-->
</script>

Then implemet it in the button:

<td>PDF<input type="radio" name="PDF" value="PDF" onclick.writeRadio()
checked>or HTML
<input type="radio" name="PDF" value="HTML" onclick.writeRadio() ></td>

but I never see the cookie set with php. What am I doing wrong?


You're mixing HTML and Javascript in a strange and illegal way,
and also making it more complicated than necessary:

<script language="javascript" type="text/javascript">
function writeRadio(a) {
document.cookie = 'showHTML=' + a
+ '; expires=Thu, 2 Aug 2008 20:47:11 UTC;'
// window.location = "http://testord.pdfkqs.local.samplelookupshow.php"
}
</script>
<td>PDF<input type="radio" name="PDF" onclick="writeRadio('PDF')"
checked>or HTML
<input type="radio" name="PDF" onclick="writeRadio('HTML')" ></td>
--

Apr 17 '07 #2

"Lee" <RE**************@cox.netwrote in message
news:f0*********@drn.newsguy.com...
Willie said:
>>
I have a php driven web app and I want the user to be able to select if
they
wmnt to see the next page in html or PDF format with a radio button.
I wrote a funtion:

<script language="javascript" type="text/javascript">
<!--
function writeRadio() {
var a;
a = document.form1.PDF.value;
document.cookie = 'showHTML=' + a + '; expires=Thu, 2 Aug 2008 20:47:11
UTC;
'
//window.location = "http://testord.pdfkqs.local.samplelookupshow.php"
}
//-->
</script>

Then implemet it in the button:

<td>PDF<input type="radio" name="PDF" value="PDF" onclick.writeRadio()
checked>or HTML
<input type="radio" name="PDF" value="HTML" onclick.writeRadio() ></td>

but I never see the cookie set with php. What am I doing wrong?

You're mixing HTML and Javascript in a strange and illegal way,
and also making it more complicated than necessary:

<script language="javascript" type="text/javascript">
function writeRadio(a) {
document.cookie = 'showHTML=' + a
+ '; expires=Thu, 2 Aug 2008 20:47:11 UTC;'
// window.location = "http://testord.pdfkqs.local.samplelookupshow.php"
}
</script>
<td>PDF<input type="radio" name="PDF" onclick="writeRadio('PDF')"
checked>or HTML
<input type="radio" name="PDF" onclick="writeRadio('HTML')" ></td>
Thanks, that was as simple as I thought it should be, I just couldn't get my
mind to see it.
Apr 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Rene | last post by:
I'm trying to learn how to use python for cgi scripts... I created a form that submits some info that I put in a cookie. Then the script calls itself and reads the cookie, and displays a...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
5
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the...
3
by: John Davis | last post by:
I created a ASP.NET Web Form using VB.NET with a text box, 2 radio buttons. When the user click the first radio button, the text will change to uppercase. If the user clicks the other radio button,...
4
by: darrel | last post by:
I'm having some problems getting a cookie set on a button click. Here is my function: Private Sub buttonSaveSettings_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
3
by: Amelyan | last post by:
When we want radio button to belong to a group name we say, radio1.GroupName="GroupA". In this case, radio1 will be unselected if another radio button is selected in "GroupA". Is there a way...
9
by: IchBin | last post by:
I can not see what the problem is with this script. I am just trying to set a radio button by calling setCheckedValue('abbr_letter', 'V'). Sorry I am new to javascript. <html> <head> <script...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
8
by: photoboy | last post by:
I have racked by brain long enough on this, so now I need the help of someone who knows what they are doing. Here is what I am trying to achieve: First, I have two radio buttons (both unchecked)...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.