Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Onchange Dropdown Variable and Javascript
Old 07-20-2010, 12:12 AM Onchange Dropdown Variable and Javascript
Novice Talker

Posts: 7
Trades: 0
Hello, I'm not sure exactly how to do this, but I was wondering if someone could help me out. I have variable $z, and it sets the number of poll options (fields) available ($z was originally a database item set by the administrator). Instead of having $z set by the admin, how could I go about having the $z variable changed by the user (when posting) via a drop down box, without submitting the page (using onChange and javascript)? And, what would the html look like for the drop down box?

Here's what I'm working with:

Code:
if ($ptype == 1) 
{
?>
<legend><?php echo $lang_polls['New poll legend'] ?></legend>
<div class="infldset">
<input type="hidden" name="ptype" value="1" />
<label><strong><?php echo $lang_polls['Question'] ?></strong><br /><input class="textbox" type="text" name="req_question" value="<?php if (isset($_POST['req_question'])) echo pun_htmlspecialchars($question); ?>" size="50" maxlength="50" tabindex="<?php echo $cur_index++ ?>" /><br /><br /></label>
<?php
$z = "15";
for ($x = 1; $x <= $z ;$x++) 
{
?>
<label><strong><?php echo $lang_polls['Option'] ?></strong><br /> <input class="textbox" type="text" name="poll_option[<?php echo $x; ?>]" value="<?php if (isset($_POST['poll_option'][$x])) echo pun_htmlspecialchars($option[$x]); ?>" size="40" maxlength="40" tabindex="<?php echo $cur_index++ ?>" /><br /></label>
<?php
} 
?></div></fieldset></div><?php   
}
xsdmx is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-20-2010, 10:51 AM Re: Onchange Dropdown Variable and Javascript
Registered User

Posts: 86
Name: John Dacu
Trades: 0
First i recommend you to use a javascript library (link jQuery) because removes many incompatibilities between browsers.
The idea for your question is to add additional html structure on onChange event. Set your target (an empty div or something, with an unique defined id), and insert there other fields or what you need
johnny.dacu is offline
Reply With Quote
View Public Profile
 
Old 07-20-2010, 12:31 PM Re: Onchange Dropdown Variable and Javascript
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,384
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You can't, it is as simple as that.

You will have to build and extend the form clientside
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Onchange Dropdown Variable and Javascript
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.28170 seconds with 12 queries