By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,605 Members | 2,128 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,605 IT Pros & Developers. It's quick & easy.

Javascript onChange event in PHP

P: 3
hi! Im having a problem retaining the inputs on my text fields. When i selected an option from a dropdown list with an onChange=location.. event. What happen is that, everytime I choose an option the page will reload then the inputs on my text field will disappear...

sample HTML:

<INPUT type="text" name="help_title" size="50">
<textarea cols="50" rows="15" name="help_content"></textarea>

<select name="main_topic" onChange="location='help_add_form.php?help_id='+th is.options[this.selectedIndex].value+'&help_sub_id='">
<option value="option">option1</option>
</select>


my question is, how can i retain the values on the input fields when an onchange event was triggered?

hope to hear from you guys! thanks!
Sep 1 '06 #1
Share this Question
Share on Google+
3 Replies


PLA
P: 44
PLA
Did you try to use a onchange="myform.submit();" instead ?
All values will be in the request, then you can give it back in the form.

<INPUT type="text" name="help_title" size="50" value="OldText">
Sep 1 '06 #2

P: 3
Did you try to use a onchange="myform.submit();" instead ?
All values will be in the request, then you can give it back in the form.

<INPUT type="text" name="help_title" size="50" value="OldText">
Thanks for your reply PLA, but how can i pass on the value of my location to the address bar if i will use myform.submit();

I'm sorry asking a lot, im new on these stuffs...
Sep 2 '06 #3

PLA
P: 44
PLA
Thanks for your reply PLA, but how can i pass on the value of my location to the address bar if i will use myform.submit();

I'm sorry asking a lot, im new on these stuffs...
Expand|Select|Wrap|Line Numbers
  1. <html>
  2.  <head>
  3.   </head>
  4.   <body>
  5.     <form action="test.php" method="PUT" name="myform">
  6.       <input type="text" name="help_title" size="50" value=<?print $help_title?>>
  7.       <textarea cols="50" rows="15" name="help_content"><?print $help_content?></textarea>
  8.       <select name="main_topic" onChange="myform.submit();">
  9.         <option value="option1" <?if ($main_topic == "option1") print selected?>>option1</option>
  10.         <option value="option2" <?if ($main_topic == "option2") print selected?>>option2</option>
  11.         <option value="option3" <?if ($main_topic == "option3") print selected?>>option3</option>
  12.       </select>
  13.     </form>
  14.   </body>
  15. </html>
May that help
Sep 4 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.