How do I set a cookie with a radio button?

W

Willie

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?
 
L

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>


--
 
W

Willie

Lee said:
Willie said:



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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top