JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 6th, 2004, 12:01 AM
aaa123 aaa123 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 2 aaa123 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
javascript and Php....(help needed)

hi,

I am having trouble getting this to work....here is the code below....it suppose to be a event driven code....the table(userProfile) is already created.....when you click the first radio button it pushes 1 into the table or else it pushes 2 into the table. But, for some reason the (if...else) structure is failing.

Can you give me a pointer or modify my code so that I can understand it .............I know php is server side and javascript is client-side.

---------------------------------------------------------------

<?php
/* Connecting, selecting database */
$link = mysql_connect(localhost , team03 , team03) or die("Could not connect");
mysql_select_db(newsreader) or die("Could not select database");
?>


<form name = "form" method="POST">

<td><font class="smallblue">Select News Type:</td> // below is where the radio buttons are being created, the name have to be the same
<td align=center width=10%><font class=medblue><input type=radio class=schedule name="R1" value="International News"><br>International News</td>
<td align=center width=10%><font class=medblue><input type=radio class=schedule name="R1" value="Sports News"><br>Sports News</td>


<script language = "javascript">
<!--
function save()
{
if (document.form.R1[0].checked) //test to see if the first radio button is clicked
{
alert("You have selected to receive International News on your PDA");


<?php
mysql_query("DELETE FROM userProfile"); // I am doing this b/c I want to remove the row, so that it will always be 1 row and not grow
$query = "INSERT INTO userProfile (choice) VALUES ('1')";
$result = mysql_query($query, $link);
?>
}
else
{
alert("You have selected to receive Sports News on your PDA");


<?php
mysql_query("DELETE FROM userProfile"); // I am doing this b/c I want to remove the row, so that it will always be 1 row and not grow
$query = "INSERT INTO userProfile (choice) VALUES ('2')";
$result = mysql_query($query, $link);
?>
}
<!--end script-->
</script>


<td class="mainftr" colspan="0" align="center">
<input type="hidden" name="pcount" value="1">
Click to save your setting:
<input class="submit" type="submit" name="process_reminder" value="Save Preferences" onclick = "save()"> //javascript is call here when the Save button is clicked
</form>
</tr></table>

<?php
/* Closing connection */
mysql_close($link);
?>

______________________________________

Ok...I am going to bed now.

Thanks
aaa123

Reply With Quote
  #2  
Old December 6th, 2004, 08:47 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
This would be better posted in the PHP forum.

Reply With Quote
  #3  
Old December 6th, 2004, 08:48 AM
MadCowDzz's Avatar
MadCowDzz MadCowDzz is offline
I'm Internet Famous
Dev Articles Frequenter (2500 - 2999 posts)
 
Join Date: Jan 2003
Location: Toronto, Canada
Posts: 2,886 MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level)MadCowDzz User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Week 16 h 19 m 35 sec
Reputation Power: 18
In the future, avoid double-posting...
Read my answer here: http://forums.devarticles.com/showt...ted=1#post39240

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > javascript and Php....(help needed)


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap