PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP 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 October 1st, 2004, 08:37 AM
Johana Solendha Johana Solendha is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 Johana Solendha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Passing values from generated select box input fields - This is driving me nuts!

Hello everyone! URL

I really need some help dears.. URL

Here's what I desperatly need to acomplish: when the user selects an option in the select box, the ID of a particular row is called and allows the input fields to echo the correspondent column values.

From what gather, I can do this via javascript.

Is there any other way?

And how can I achieve this?

Thank for all the help! URL
PHP Code:
<?php 
mysql_connect
($config['sql_host'], $config['sql_username'], $config['sql_password']); 
    
mysql_select_db($config['sql_database']); 
        
$sql mysql_query("SELECT packname,packvalue,packdescription FROM packs "); 
echo 
"<table>"
echo 
"<tr><td>Please choose: "
echo 
"<select name='packselected' size='1'>"
while (
$r mysql_fetch_array($sql)) 

    echo 
"<option value='"$r['packvalue'] ."'>"$r['packname'] ."</option>"

echo 
"</select></td></tr>"
echo 
"</table>"
?> 
      <p>Edit Point Packs value:<br> 
        <input name="packvalue" type="text" size="10" value="<?php $query mysql_query("SELECT packvalue FROM packs"); $row mysql_fetch_array($query); echo "$row[packvalue]"?>"> 
      </p> 
        <p>Pack Name:<br> 
          <input name="packname" type="text" size="20" value="<?php $query mysql_query("SELECT packname FROM packs"); $row mysql_fetch_array($query); echo "$row[packname]"?>"> 
        </p> 
      <p>Pack description:<br> 
        <textarea name="packdescription" value="<?php $query mysql_query("SELECT packdescription FROM packs"); $row mysql_fetch_array($query); echo "$row[packdescription]"?>"><?php $query mysql_query("SELECT packdescription FROM packs"); $row mysql_fetch_array($query); echo "$row[packdescription]"?></textarea> 
      </p> 
      <p> 
        <input type="submit" name="Submit" value="Update Settings"> 
      </p></td> 
  </tr> 
</table> 
</form>

Reply With Quote
  #2  
Old October 1st, 2004, 02:32 PM
xlordt xlordt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: 127.0.0.1
Posts: 20 xlordt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 39 sec
Reputation Power: 0
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt
do you want that on focus or are you adding a submit button for this? also.. no offence but your code is messy kinda makes it hard to read so i really cant understand it. Why not use Javascript?

Reply With Quote
  #3  
Old October 1st, 2004, 02:35 PM
Johana Solendha Johana Solendha is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 Johana Solendha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by xlordt
do you want that on focus or are you adding a submit button for this? also.. no offence but your code is messy kinda makes it hard to read so i really cant understand it. Why not use Javascript?

Sorry about the code!

The submit button will update data in my table. I know I can use javascript, the problem is how.

Reply With Quote
  #4  
Old October 1st, 2004, 02:56 PM
xlordt xlordt is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Location: 127.0.0.1
Posts: 20 xlordt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 39 sec
Reputation Power: 0
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt
Quote:
Originally Posted by Johana Solendha
Sorry about the code!

The submit button will update data in my table. I know I can use javascript, the problem is how.

Ok, currently i dont have db connection because im upgrading my other system.. but i will post something that you can work with that will surely help you alot

*Edited*
PHP Code:
<?php

 $texts  
= array( => "This is text field",
                  
=> "This is a Text field 2" );
?>

<script>
  function Populateit( )
  {
     var vals = "<?php echo $_POST['optionsz']; ?>";
     
     document.getElementById( "forms" ).elements[vals].value = "<?php echo $texts[$_POST['optionsz']]; ?>";
  }
</script>

<form method="post" action="hello.php" name="form" id="forms" onSubmit="Populateit( );">
 <select name="optionsz">
  <option value=1>Text Field</option>
  <option value=2>Text Area</option>
 </select>
<input type="text" name="tests"><br />
<input type="text" name="tests2"><br />
<input type="submit" name="submit" value="Submit">
<br />
</form>

havent tested it.. so i dont know if it will fully work.. but looks like it does.. anyways.. if not i will hit you up laters

Reply With Quote
  #5  
Old October 1st, 2004, 04:09 PM
Johana Solendha Johana Solendha is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 Johana Solendha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by xlordt
Ok, currently i dont have db connection because im upgrading my other system.. but i will post something that you can work with that will surely help you alot

*Edited*
hehe hold forgot you wanted it from the option box

Thank you so much for the assistance!

Reply With Quote
  #6  
Old October 1st, 2004, 07:31 PM
Johana Solendha Johana Solendha is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 4 Johana Solendha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you so much, but I don't think I explianed myself well.


I need the combo box to changer the values of the input fields. The values are fetched from the database.

Reply With Quote
  #7  
Old October 2nd, 2004, 01:29 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
Essentially you are looking to do the following:

a. Query the database and return a specific amount or records
b. Place all records into Javascript variables in the page
c. Once a select box is changed, the value triggers the appropriate javascript variable and the values are pulled up into the input box fields.

Does this get it? I hope this helps. From here you should be able to write all the code yourself.
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Passing values from generated select box input fields - This is driving me nuts!


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 5 hosted by Hostway
Stay green...Green IT