473,782 Members | 2,699 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically change variables in FORM whithout reload page

1 New Member
Hi all!
How can i do this:

[HTML]<form method="get" action="test.as p" >
<input name="boys" type=radio value="John">Jo hn
<input name="boys" type=radio value="Lu">Lu
<input name="boys" type=radio value="James">J ames
<input name="student" type=checkbox value="yes">stu dent?
[/HTML]
and now: if student=yes then this boy is a student:

[HTML] <input type=hidden name="message1" value="he is a student">
<input type=hidden name="message2" value="welcome" >
[/HTML]
or if student not "yes" then boy is not a student:

[HTML] <input type=hidden name="message1" value="who is it">
<input type=hidden name="message2" value="bye">

<input type="submit" value="Ок">
</form>[/html]

Thanks
Sep 9 '06 #1
1 3608
acoder
16,027 Recognized Expert Moderator MVP
Add an onclick to the checkbox to call a function:
[HTML]<input name="student" type=checkbox value="yes" onclick="isStud ent(this)">stud ent?[/HTML]
Add an id to the hidden field for easy access:[HTML] <input id="message1" type=hidden name="message1" value="he is a student">[/HTML]
and now onto the javascript:
Expand|Select|Wrap|Line Numbers
  1. function isStudent(checkbox) {
  2.     var hidden = document.getElementById("message1");
  3.     if (checkbox.checked) {
  4.         hidden.value="this is a student";
  5.     } else {
  6.         hidden.value = "not a student";
  7.     }
  8. }
May 14 '08 #2

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

Similar topics

3
2110
by: Dave Nouwens | last post by:
Hi All, Please accept my appologies in advance for what I expect will be a reasonably simple question. I have an html form (which is generated in php) which contains a number of rows (one row per product in the 'products' table). It is generated with the following php
2
2211
by: Ola Fjelddahl | last post by:
hi. I load a script dynamically and it works * everytime with IE6. * sometimes! with Mozilla1.5 <- makes me curious * never with Opera7.11 all tests on WindowsXP. With "sometimes" I mean
10
2199
by: Randy Webb | last post by:
This page: http://www.hikksworld.com/loadJSFiles/ Is one where I was testing the ability of browsers that can/can't dynamically load a JS file with one of the three methods: 1)Changing the src property of a script tag. 2)Inserting a script src="" tag in a div via innerHTML 3)Using document.createElement to add a script element. The fourth method on the page is writing a script tag to a layer, and to the best of my knowledge it only...
3
2382
by: Varad | last post by:
Hi all Pls give me some insight as to what I should be doing. I have a form where I have 20 text boxes and when an user submits the form I save it to a database. When they want to retrieve it, I loop and create the textboxes with ID and text value and then add to the form. The problem is when trying to create the control in the code behind page I get the error "Multiple controls with the same ID 'txtQLLink1' were found". How do I retrieve...
1
2376
by: Knud | last post by:
I have a frameset where a hidden frame reloads every 5 seconds and collects data from the sever if there are any changes made in a database. The hidden page updates Div fields on other frames with the lastest information. This works great. The problem I have is that when the hidden frame reloads it steals focus from the main frame where a user can be entering information into a form. (This is very annoying. As tabing through form...
8
4316
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image button at runtime: //----- Code snippet protected System.Web.UI.WebControls.PlaceHolder ImageHolder; private void Page_Load(object sender, System.EventArgs e)
2
1434
by: Wee Bubba | last post by:
my page is split into 2 frames. my upper frame contains a data entry form consisting of asp.net textbox server controls. my lower frame displays rows of data. when a user clicks the submit button in the upper frame I want the textfield contents to be validated then I want to send the form variables to the page in my lower frame forcing it to refresh. my lower frame will then get these variables, use them to insert a new row then will...
10
7244
by: EOZyo | last post by:
Hi, i'm trying to set pagination for a search i run on my website, i'll try to explain the easiest i can: When i click the search button on search.php, data is received and stored in variables within results.php, MySQL structure seems to work as expected, although i get some problems: As soon as i click on the "Page 2" Link, i get nothing, neither results nor page numbers.
1
7552
Merlin1857
by: Merlin1857 | last post by:
How to search multiple fields using ASP A major issue for me when I first started writing in VB Script was constructing the ability to search a table using multiple field input from a form and having the sql statement dynamically built according to the input provided by the user. I have used the method described here hundreds of times it is quick and adaptive. I generally use a frames page for the search, in this way the search is maintained...
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10143
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8964
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4040
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.