Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Old 01-15-2007, 10:41 PM   #1 (permalink)
Senior Member
 
Join Date: 01-02-07
Location: PA, USA
Posts: 191
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
JavaScript is evil, I swear

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head><title>HIDDEN</title> <link rel="icon" href="favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link rel="stylesheet" type="text/css" href="styles.css" /></head> <body><form method="get" name="user" action="/forum/profile.php"> <select name="member_id" id="member_id" onChange="document.user.member_id.options[document.user.member_id.selectedIndex].value" ><option value="1">HIDDEN</option><option value="2">HIDDEN</option><option value="3">HIDDEN</option><option value=""></option><option value="5">HIDDEN</option><option value="6">HIDDEN</option><option value="7">HIDDEN</option><option value="8">HIDDEN</option><option value="9">HIDDEN</option><option value="10">HIDDEN</option></select></form><table class="forum"> <tr><td>Name:</td><td>HIDDEN</td></tr> <tr><td>Address:</td><td>HIDDEN</td></tr> <tr><td>Tele:</td><td>HIDDEN</td></tr> </table><p><a href="profedit.php">Edit Profile</a></p><p><a href="index.php">Main</a></p> </body> </html>
As far as I know this should work so that when I select an option from the dropdown box it'll change the Name: Address: Tele: fields, I used PHP and MySQL for those fields, when I use a normal form, with a submit button it works fine, so I know it's not that part, it's only the change when an option is selected that's causing a problem. Also option 4 is meant to be missing.
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-16-2007, 10:57 AM   #2 (permalink)
Senior Member
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 663
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Hmmm. It looks like the Javascript onchange event is telling your select element to adopt the value of ... whatever you selected in that element. There's no need for Javascript, here, that's default select element behavior. You haven't included anything else, so it doesn't do anything else.

Are you trying to execute an AJAX routine that populates the table values with values drawn from a db when the select element is changed? Your code as posted doesn't go far enough. The onchange event needs to trigger the AJAX routine. As it is, there's nothing wrong with this except the extraneous script.

All that aside, Javascript can seem pretty evil, at times.
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-16-2007, 11:34 AM   #3 (permalink)
Senior Member
 
Join Date: 01-02-07
Location: PA, USA
Posts: 191
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
I'm trying to do the type of thing they are trying to explain on this site http://www.netmechanic.com/news/vol3...cript_no12.htm I'm using PHP to populate the options, but I want to use Javascript to make it so that when I select the option the user doesn't have to use a submit button, it'll automatically change the page.
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-16-2007, 04:55 PM   #4 (permalink)
Senior Member
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 663
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Oh, okay:
Code:
<select onchange="if (this.value) { top.location.href=this.value; }"> <option value=0 />Choose: <option value="somepage.php" />Some Page <option value="nextpage.php" />Next Page <option value="lastpage.php" />Last Page </select>
Similarly:
Code:
<script ...> var pgs=new Array(null,"somepage.php","nextpage.php","lastpage.php"); </script> <select onchange="if (this.value) { top.location.href=pgs[this.value]; }"> <option value=0 />Choose: <option value=1 />Some Page <option value=2 />Next Page <option value=3 />Last Page </select>
Badda bing!

Last edited by StupidScript; 01-16-2007 at 04:59 PM..
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-16-2007, 10:15 PM   #5 (permalink)
Senior Member
 
Join Date: 01-02-07
Location: PA, USA
Posts: 191
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
I really don't like JS, I never learned it because I though I'd never need it, or use it either. The page is still not working even though I tried to fix it.

Code:
<select name="member_id" id="member_id" onChange="if (this.value) {top.location.href=profile.php?member_id=this.value;}"><option value="1">HIDDEN</option><option value="2">HIDDEN</option><option value="3">HIDDEN</option><option value=""></option><option value="5">HIDDEN</option><option value="6">HIDDEN</option><option value="7">HIDDEN</option><option value="8">HIDDEN</option><option value="9">HIDDEN</option><option value="10">HIDDEN</option></select></form>
Any suggestions?
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-16-2007, 11:09 PM   #6 (permalink)
Senior Member
 
StupidScript's Avatar
 
Join Date: 09-22-06
Location: Los Angeles
Posts: 663
iTrader: 0 / 0%
Latest Blog:
None

StupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really niceStupidScript is just really nice
Yep. A string is a string ...
Code:
onChange="if (this.value) { top.location.href=profile.php?member_id=this.value; }"
should be
Code:
onChange="if (this.value) { top.location.href='profile.php?member_id='+this.value; }"
Note the string delineators, the ' characters around the 'non-JSvariable' parts.

Go nuts! (And check out javascriptkit.com for some fundamentals.)
StupidScript is offline  
Add Post to del.icio.us
Reply With Quote
Old 01-17-2007, 01:54 AM   #7 (permalink)
Senior Member
 
Join Date: 01-02-07
Location: PA, USA
Posts: 191
iTrader: 0 / 0%
Latest Blog:
None

Arenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebodyArenlor is liked by somebody
Send a message via ICQ to Arenlor Send a message via AIM to Arenlor Send a message via MSN to Arenlor Send a message via Yahoo to Arenlor
Whoot! It works, thanks a lot dude ^_^ I'll have to check out that site and start building my knowledge of JS up.
Arenlor is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript - Function is undefined (But I defined it, I swear!) pipelineae Coding Forum 1 03-09-2008 08:16 AM
I swear we'll all drown John Scott Forum Lobby 71 01-10-2007 06:50 PM
I swear I've been here before ... dewebsign Google Forum 10 11-26-2003 06:43 PM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 05:58 AM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.