User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 401,948 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,366 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 2376 | Replies: 5
Reply
Join Date: Jun 2006
Posts: 61
Reputation: sgriffiths is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sgriffiths sgriffiths is offline Offline
Junior Poster in Training

Submit or action button

  #1  
Nov 2nd, 2006
Hello

I have a web page which has a drop down menu.
I want the user to select an option from the drop down menu, then click submit.

This will then activate my php script and select data from my MYSQL database and populate the fields.

How do i action a button, so when i click, it activates a peice of html / php code?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: India
Posts: 1,289
Reputation: vishesh is on a distinguished road 
Rep Power: 4
Solved Threads: 32
vishesh's Avatar
vishesh vishesh is offline Offline
Nearly a Posting Virtuoso

Re: Submit or action button

  #2  
Nov 2nd, 2006
use onChange event.
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Submit or action button

  #3  
Nov 2nd, 2006
Client vs. Server. The only thing that will "activate" PHP code is a server request. There are two types of server request, GET, and POST. GET requests happen by typing in a URL or clicking a link. POST requests happen when you submit a form.

As far as "activating" HTML code... that happens when the browser renders a page. I think you mean JavaScript code, and there are lots of ways to run JavaScript. Every HTML element has associated JavaScript events and event handlers. You, as a developer, have to code them.

The thread title seems to indicate you want to know the difference between a submit button and a regular button, but you don't ask that in your post. You're going to have to narrow things down to a specific question. Which piece of the puzzle can you not do?

1. Write an HTML form with a dropdown list and a submit button?
2. Write a PHP program to process the form results?
3. Query a MySQL database?
4. Process the query results and output new HTML?
Last edited by tgreer : Nov 3rd, 2006 at 9:52 am. Reason: Fixed typo/grammar.
Reply With Quote  
Join Date: Jun 2006
Posts: 61
Reputation: sgriffiths is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
sgriffiths sgriffiths is offline Offline
Junior Poster in Training

Re: Submit or action button

  #4  
Nov 3rd, 2006
ok ok

What i wanted was an onChange option, this then calls a javascript procedure

But i need the procedure to be php with embedded html
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Submit or action button

  #5  
Nov 3rd, 2006
Re-read my post. PHP is server-side code. JavaScript is client-side code. You cannot write PHP that will run on the client in response to a JavaScript onChange event. I don't know what "embedded HTML" means in this context, sorry.
Reply With Quote  
Join Date: Sep 2005
Posts: 674
Reputation: digital-ether has a spectacular aura about digital-ether has a spectacular aura about 
Rep Power: 5
Solved Threads: 39
Moderator
digital-ether's Avatar
digital-ether digital-ether is offline Offline
Practically a Master Poster

Help Re: Submit or action button

  #6  
Nov 6th, 2006
Originally Posted by sgriffiths View Post
ok ok

What i wanted was an onChange option, this then calls a javascript procedure

But i need the procedure to be php with embedded html


Like mentioned, JavaScript is client side (runs on the browser) and PHP is server side (runs on the server).

Regarding: "php with embedded html".
I believe you mean PHP embeded in HTML. This is a confusing statement that "sells" PHP when you are new to the language. It doesn't mean that PHP is embedded in HTML some how literally speaking. All php is processed on the server and only HTML is sent to the browser. It just means that you can seperate PHP in <?PHP ?> tags and place this in between your HTML.

So in order to use PHP, you'll have to make a request to the server, as mentioned with a form POST, or a GET request.

This equates to a new page load on the browser. Or a refreshing of a hidden Iframe or use of AJAX if you dont want to reload the page.

I believe what you want is simple a new page load, as that is the simplest and most conventional.

If you want to make a GET request using JavaScript, you can use:

window.location = 'http://example.com';

If you need to submit a form automatically, use form.submit(); where "form" is the form object defined in the DOM.

Exaple:
make a HTTP GET on selecting a new option.

[HTML]<select name="selectbox" id="selectbox">
<option value="">Select a Page</option>
<option value="http://example.com/page1.php">Page 1</option>
<option value="http://example.com/page2.php">Page 2</option>
</select>

<script type="text/javascript">


var select = document.getElementById('selectbox');
select.onchange = function() {
window.location = select.options[select.selectedIndex].value;
}

</script>[/HTML]
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb JavaScript / DHTML / AJAX Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 5:22 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC