942,778 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 708
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Mar 10th, 2010
1

Very Easy for you all PHP Gurus

Expand Post »
Hi

My problem is that I want Other textbox tobe deactivated when page loads, but when user selects Other drop down box of Company Certification: then Other textbox should be activated.

Please see here

Here is the PHP code which is displaying this page
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. echo "<select name=\"company_certification\">";
  3. echo "<option value=\"ISO2001\">ISO2001</option>";
  4. echo "<option value=\"OTHER\">Other</option>";
  5. echo "<option value=\"None\">None</option>";
  6. echo "</select>";
  7. ?>
  8.  
  9. <?php echo "Other:"; ?>
  10. <?php echo zen_draw_input_field('other_certification', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'customer_company_other_certification', '40') . ' id="other_certification"') . (zen_not_null(ENTRY_COMPANY_TEXT) ? '<span class="alert">' . ENTRY_COMPANY_TEXT . '</span>': ''); ?>

And I found a java script which is this
PHP Syntax (Toggle Plain Text)
  1. <html xmlns="http://www.w3.org/1999/xhtml">
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4. <title>Untitled Document</title>
  5.  
  6. <script type="text/javascript">
  7.  
  8. function change(val)
  9. {
  10. if (val=="Other")
  11. {
  12. document.getElementById("txt").innerHTML="<input type=\"text\" id=\"other\" name=\"other\"/>";
  13. }
  14. else
  15. {
  16. document.getElementById("txt").innerHTML="<input type=\"text\" id=\"other\" name=\"other\" disabled/>";
  17. }
  18. }
  19. </script>
  20. </head>
  21.  
  22. <body>
  23.  
  24. <form name="f1">
  25.  
  26. <select name="s1" onchange="change(this.value)" onchange="change(this.value)">
  27. <option value="ISO2000">ISO2000</option>
  28. <option value="ISI">ISI</option>
  29. <option value="Other">Other</option>
  30. </select>
  31.  
  32. <div id="txt">
  33. <input type="text" id="other" name="other" disabled/>
  34. </div>
  35.  
  36.  
  37. </form>
  38.  
  39. </body>
  40. </html>

Can I use this java script in my php code mentioned above.

Please help me...

Thank you all in advance
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vishalonne is offline Offline
69 posts
since Jun 2009
Mar 10th, 2010
0
Re: Very Easy for you all PHP Gurus
Click to Expand / Collapse  Quote originally posted by vishalonne ...
Hi

...

Can I use this java script in my php code mentioned above.

Please help me...

Thank you all in advance
Not as shown in your code. In Javascript you would have to reference existing ID tags in the HTML code. So you would need something like
PHP Syntax (Toggle Plain Text)
  1. <p id="this_is_the_target"></p>
And then a Javascript code of
PHP Syntax (Toggle Plain Text)
  1. obj = getElementById('this_is_the_target');
  2. obj.innerHTML = "Something new";
Please note that this is just pseudo code. So its not meant to be used literally. You could for example do some field substitution when you fill the innerHTML.
Reputation Points: 9
Solved Threads: 9
Junior Poster in Training
maba001 is offline Offline
55 posts
since Jun 2008
Mar 10th, 2010
0
Re: Very Easy for you all PHP Gurus
Click to Expand / Collapse  Quote originally posted by maba001 ...
Not as shown in your code. In Javascript you would have to reference existing ID tags in the HTML code. So you would need something like
PHP Syntax (Toggle Plain Text)
  1. <p id="this_is_the_target"></p>
And then a Javascript code of
PHP Syntax (Toggle Plain Text)
  1. obj = getElementById('this_is_the_target');
  2. obj.innerHTML = "Something new";
Please note that this is just pseudo code. So its not meant to be used literally. You could for example do some field substitution when you fill the innerHTML.
Another note - I reread your posting. The easier way would be to be to do getElementById directly on the input box and then set the enabled / disabled flag directly.
Reputation Points: 9
Solved Threads: 9
Junior Poster in Training
maba001 is offline Offline
55 posts
since Jun 2008
Mar 11th, 2010
0

Not so easy

Hi

Thank you for your guidance but, I am using Zen cart and it is not possible to change all the code of Zen cart it may mess up the site.

If I forget about Javascript is it possible to do the job what I require purely in PHP
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vishalonne is offline Offline
69 posts
since Jun 2009
Mar 11th, 2010
0
Re: Very Easy for you all PHP Gurus
Click to Expand / Collapse  Quote originally posted by vishalonne ...
Hi
..
If I forget about Javascript is it possible to do the job what I require purely in PHP
I guess "No". The function you want to achieve is in the browser (purely client side). So it must be done at the client which means Javascript or some other client side language. But Javascript is probably the easiest one and the one which works across most browsers.
Reputation Points: 9
Solved Threads: 9
Junior Poster in Training
maba001 is offline Offline
55 posts
since Jun 2008
Mar 11th, 2010
0
Re: Very Easy for you all PHP Gurus
how can open .doc file in php
Reputation Points: 10
Solved Threads: 0
Newbie Poster
brijendra1 is offline Offline
5 posts
since Mar 2010
Mar 11th, 2010
0
Re: Very Easy for you all PHP Gurus
Click to Expand / Collapse  Quote originally posted by maba001 ...
I guess "No". The function you want to achieve is in the browser (purely client side). So it must be done at the client which means Javascript or some other client side language. But Javascript is probably the easiest one and the one which works across most browsers.
While that is true there is a thing called ajax. I would suggest following an ajax tutorial where javascript can communicate with php after the page has loaded.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,003 posts
since Sep 2007
Mar 11th, 2010
0
Re: Very Easy for you all PHP Gurus
hello sir,i have a prob in code..i want to view uploaded resume file(Ex.-maurya.dco).format of resume is like same as doc file
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maurya.nitin1 is offline Offline
2 posts
since Mar 2010
Mar 11th, 2010
0
Re: Very Easy for you all PHP Gurus
Click to Expand / Collapse  Quote originally posted by vishalonne ...
Hi

Thank you for your guidance but, I am using Zen cart and it is not possible to change all the code of Zen cart it may mess up the site.

If I forget about Javascript is it possible to do the job what I require purely in PHP
please help me how to show a .doc file in same format in block or browser
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maurya.nitin1 is offline Offline
2 posts
since Mar 2010
Mar 11th, 2010
0
Re: Very Easy for you all PHP Gurus
Thank you again for your time and guidance can you provide me how to use javascript in my php code
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vishalonne is offline Offline
69 posts
since Jun 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP File Upload Error
Next Thread in PHP Forum Timeline: PHP Pagination , please help ....





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC