Do not use on any
shared computer
August 30, 2008 09:07am pdt
 
[x]
Attachment Details

retrieve value for hidden field

Tags: php
hello. how can i get the vaule of a form field before it is posted? example below. the value i am trying to get is once a selection is made from the select statement to_frm then i need the id of this user to pass in a hidden field, idusr_frm. i think the database is correct and as you can see, i have tried with isset but seeing as the value isn't posted, cannot use that statement. any help? many thanks
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
DATABASE
 
mysql_select_db($database_conn, $conn);
$query_Recordset1 = "SELECT user_usr.name_usr, user_usr.id_usr, contact_frm.idusr_frm, contact_frm.from_frm, contact_frm.subject_frm, contact_frm.to_frm, contact_frm.date_frm, contact_frm.read_frm FROM (contact_frm LEFT JOIN user_usr ON user_usr.name_usr=contact_frm.to_frm) ";
$Recordset1 = mysql_query($query_Recordset1, $conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
 
mysql_select_db($database_conn, $conn);
$query_Recordset2 = "SELECT id_usr, name_usr FROM user_usr";
$Recordset2 = mysql_query($query_Recordset2, $conn) or die(mysql_error());
$row_Recordset2 = mysql_fetch_assoc($Recordset2);
$totalRows_Recordset2 = mysql_num_rows($Recordset2);
 
--------------------------------------------------------------
 
FORM
 
<select name="to_frm_<?php echo $cnt1; ?>" id="to_frm_<?php echo $cnt1; ?>">
                            <option value=""><?php echo NXT_getResource("Select one..."); ?></option>
                            <?php 
do {  
?>
                            <option value="<?php echo $row_Recordset2['name_usr']?>"<?php if (!(strcmp($row_Recordset2['id_usr'], $row_rscontact_frm['to_frm']))) {echo "SELECTED";} ?>><?php echo $row_Recordset2['name_usr']?></option>
                            <?php
} while ($row_Recordset2 = mysql_fetch_assoc($Recordset2));
  $rows = mysql_num_rows($Recordset2);
  if($rows > 0) {
      mysql_data_seek($Recordset2, 0);
	  $row_Recordset2 = mysql_fetch_assoc($Recordset2);
  }
?>
                          </select>
                              <?php echo $tNGs->displayFieldError("contact_frm", "to_frm", $cnt1); ?> </td>
                        </tr>
                        <tr>
                          <td class="KT_th"><label for="subject_frm_<?php echo $cnt1; ?>">Subject:</label></td>
                          <td><input type="text" name="subject_frm_<?php echo $cnt1; ?>" id="subject_frm_<?php echo $cnt1; ?>" value="<?php echo KT_escapeAttribute($row_rscontact_frm['subject_frm']); ?>" size="32" maxlength="255" />
                              <?php echo $tNGs->displayFieldHint("subject_frm");?> <?php echo $tNGs->displayFieldError("contact_frm", "subject_frm", $cnt1); ?> </td>
                        </tr>
                        <tr>
                          <td class="KT_th"><label for="date_frm_<?php echo $cnt1; ?>">Date:</label></td>
                          <td><input name="date_frm_<?php echo $cnt1; ?>" id="date_frm_<?php echo $cnt1; ?>" value="<?php echo KT_formatDate($row_rscontact_frm['date_frm']); ?>" size="10" maxlength="22" wdg:subtype="Calendar" wdg:mask="<?php echo $KT_screen_date_format; ?>" wdg:type="widget" wdg:mondayfirst="false" wdg:singleclick="true" wdg:restricttomask="yes" wdg:readonly="true" />
                              <?php echo $tNGs->displayFieldHint("date_frm");?> <?php echo $tNGs->displayFieldError("contact_frm", "date_frm", $cnt1); ?> </td>
                        </tr>
                        <tr>
                          <td class="KT_th"><label for="message_frm_<?php echo $cnt1; ?>">Message:</label></td>
                          <td><textarea name="message_frm_<?php echo $cnt1; ?>" cols="50" rows="5" id="message_frm_<?php echo $cnt1; ?>" wdg:subtype="RestrictedTextArea" wdg:type="widget" wdg:maxchars="255" wdg:showcount="true" wdg:showmessage="true"><?php echo KT_escapeAttribute($row_rscontact_frm['message_frm']); ?></textarea>
                              <?php echo $tNGs->displayFieldHint("message_frm");?> <?php echo $tNGs->displayFieldError("contact_frm", "message_frm", $cnt1); ?> </td>
                        </tr>
                      </table>
<input type="hidden" name="from_frm_<?php echo $cnt1; ?>" id="from_frm_<?php echo $cnt1; ?>" value="Admin" />
<input type="hidden" name="read_frm" value="1" />
<input type="hidden" name="idusr_frm" id="idusr_frm" value="<?php if (isset($_POST['to_frm'])) {
qry = mysql_query("SELECT * FROM `user_usr` WHERE `name_usr` = '{$_POST['to_frm']}'");} echo $qry['id_usr'];?>"/>
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Web Development
Question Asked By: peter_coop
Solution Provided By: Xyptilon2
Participating Experts: 2
Solution Grade: A
Views: 80
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by tusharkanvinde
Expert Comment by tusharkanvinde:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by Xyptilon2

Rank: Master

Expert Comment by Xyptilon2:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by peter_coop
Author Comment by peter_coop:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Accepted Solution by Xyptilon2

Rank: Master

Accepted Solution by Xyptilon2:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628