Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old May 24th, 2005, 07:58 PM
mrmuro mrmuro is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Cary, NC, USA
Posts: 1 mrmuro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Radio Buttons/Instant update

Hello All,
I am relatively a newbie to the world of PHP and java script. Actually, I am a windows developer asked to develop a web page.

Here is the basic issue:
There is a "category" represented by 2 radio buttons. Followed by 2 select boxes.

The desired behaviour:
1. The user selects a radio button
2. This updates the contents of the first select box
3. Selecting an item from the first select box will update the second select box
4. Selecting an item from the second select box will update an image box
All this needs to happen without the user hitting a submit button.

I know enough PHP to be dangerous, so here I am reaching out. This is what I have so far. I am stuck at step 2:

My java script
<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
function RefreshPersonalLayouts(){
if(document.templategallery.isPersonal.value=1){
document.templategallery.layoutsql.value="SELECT DISTINCT `Name` FROM `tblTemplates` WHERE `isPersonal`= 1 ORDER BY `Name`";
document.templategallery.refresh();
}
}
function RefreshBusinessLayouts(){
if(document.templategallery.isPersonal.value=2){
document.templategallery.layoutsql.value="SELECT DISTINCT `Name` FROM `tblTemplates` WHERE `isBusiness`= 1 ORDER BY `Name`";
}
}
function RefreshColors() {
}
</script>

php Code:
Original - php Code
  1.  
  2. <FORM name="templategallery" method="POST";>
  3. <INPUT type=hidden name="layoutsql";> <P></P>
  4.  
  5. <FIELDSET style="PADDING-RIGHT: 2px; PADDING-LEFT: 2px; PADDING-BOTTOM: 2px; WIDTH: 567px; PADDING-TOP: 2px; HEIGHT: 44px"><LEGEND><FONT face=Arial color=#000000 size=3>Select the type of the website:</FONT></LEGEND><FONT face=Arial>
  6. <INPUT type=radio value=1 name=isPersonal OnClick=RefreshPersonalLayouts();>
  7. <FONT size=3>Personal&nbsp;</FONT>&nbsp;&nbsp;&nbsp;&nbsp;
  8. <INPUT type=radio value=2 name=isPersonal OnClick=RefreshBusinessLayouts();>
  9. <FONT size=3>Business</FONT></FIELDSET></FONT>
  10. <P><FONT face=Arial size=3>Select the layout of the website:</FONT></P>
  11. <P><FONT face=Arial><SELECT style="WIDTH: 184px; HEIGHT: 134px" size=8 name=previewlayouts>
  12. <?php
  13. $connection=mysql_connect(HostNAme,"username","password") or die("couldn't connect to server");
  14. $db=mysql_select_db("mrmuro_templates",$connection) or die("couldn't select db");
  15.  
  16. $sql=document.templategallery.layoutsql.value;
  17. $sql_result=mysql_query($sql,$connection) or die("couldn't get layouts");
  18.  
  19.  
  20. while($row=mysql_fetch_array($sql_result))
  21. {
  22.   $layoutName=$row["Name"];
  23.   echo "<OPTION> $layoutName </OPTION>";
  24. }
  25. ?>
  26. </SELECT></P>
  27. <P>
  28. <TABLE cellSpacing=0 cellPadding=0 width="70%" border=0>
  29. <TBODY>
  30. <TR>
  31. <TD>
  32. <P>Select the color of the website:</P>
  33. <P><FONT face=Arial><SELECT style="WIDTH: 179px; HEIGHT: 70px" size=4 name=previewcolors>
  34. </SELECT>
  35. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT></P>
  36. <P>&nbsp;</P></TD>
  37. <TD vAlign=top>
  38. <P>&nbsp;Website Theme Preview:</P>
  39. <P align=left><INPUT type=image height=122 width=150 src="images/templates/preview.bmp" border=0 name=previewImage></P></TD></TR></TBODY></TABLE></P></FONT>
  40. </FORM>


Any insight/tips or help will be greatly appreciated. I have been trying to use a hidden field to pass the sql statement around but that is not working. I believe there is a fundamental piece missing in all of this.

Reply With Quote
  #2  
Old May 29th, 2005, 06:58 PM
boro boro is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 6 boro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: Radio Buttons/Instant update

Hope this will help:

I am posting just javascript, so you must edit some HTML tags too.
__________________________________________________ ______
HTML:

<SELECT style="WIDTH: 184px; HEIGHT: 134px" size=8 name=previewlayouts onClick="RefreshColors();">

<SELECT style="WIDTH: 179px; HEIGHT: 70px" size=4 name=previewcolors onClick="RefreshImage();">

THE RIGHT WAY TO ADD IMAGE TO THE PAGE:
<IMG height=122 width=150 src="PATH/IMAGE.GIF" border=0 name=previewImage />
__________________________________________________ ________
javascript:

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">


//Loading images for use in js -------------------------------------------------
if(document.images){

var blue = new Image();
blue.src = "blue.gif";
var red = new Image();
red.src = "red.gif";
var white = new Image();
white.src = "white.gif";
var black = new Image();
black.src = "black.gif";
}
//------------------------------------------------------------------------------

function RefreshPersonalLayouts(){
if(document.templategallery.isPersonal.value=1){
document.templategallery.layoutsql.value="SELECT DISTINCT `Name` FROM `tblTemplates` WHERE `isPersonal`= 1 ORDER BY `Name`";


//Setting the the options in select boxes --------------------------------------
var style1 = new Option("colours", false);
var style2 = new Option("B&W", false);
document.templategallery.previewlayouts.options[0] = style1;
document.templategallery.previewlayouts.options[1] = style2;
//------------------------------------------------------------------------------

}
}
function RefreshBusinessLayouts(){
if(document.templategallery.isPersonal.value=2){
document.templategallery.layoutsql.value="SELECT DISTINCT `Name` FROM `tblTemplates` WHERE `isBusiness`= 1 ORDER BY `Name`";

}
}
function RefreshColors() {


//------------------------------------------------------------------------------
if(document.templategallery.previewlayouts.selecte dIndex != -1){

var colour1;
var colour2;

if(document.templategallery.previewlayouts.selecte dIndex == 0){

colour1 = new Option("blue", false);
colour2 = new Option("red", false);
document.templategallery.previewcolors.options[0] = colour1;
document.templategallery.previewcolors.options[1] = colour2;

}else{

colour1 = new Option("white", false);
colour2 = new Option("black", false);
document.templategallery.previewcolors.options[0] = colour1;
document.templategallery.previewcolors.options[1] = colour2;

}
}
//------------------------------------------------------------------------------
}

function RefreshImage(){

//Changing the image------------------------------------------------------------

var colour = document.templategallery.previewcolors.options[document.templategallery.previewcolors.selectedInd ex].text;
var imageName = eval(colour + '.src'); //you get string : black.src

document.images["previewImage"].src = imageName;


//------------------------------------------------------------------------------
}
</script>

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Radio Buttons/Instant update


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway