Sponsored Content
Top Forums Web Development Help with passing HTML values in to JavaScript Post 302457568 by fpmurphy on Tuesday 28th of September 2010 09:50:59 AM
Old 09-28-2010
Here is one solution using ids:
Code:
<html>
<head>

<script language="javascript" type="text/javascript">
    function fillcap() {
      
        var wire = document.getElementById("wire").value;
        var conduit = document.getElementById("cond").value;

        if (wire >= "10" && conduit == "1") {
            alert("Wire Size exceeds conduit max fill!")
        }  else {
            alert("Blah Blah!")
        }

    }
</script>

</head>
<body>
<form name="form">
        <h2>Fill Capacity</h2>
        <b>Wire Size</b><br>
        <select id="wire">
        <option value="1">#14</option> 
        <option value="2">#12</option> 
        <option value="3">#10</option>
        <option value="4">#8</option> 
        <option value="5">#6</option> 
        <option value="6">#4</option>
        <option value="7">#3</option> 
        <option value="8">#2</option> 
        <option value="9">#1</option>
        <option value="10">1/0</option> 
        <option value="20">2/0</option> 
        <option value="30">3/0</option>
        <option value="40">4/0</option>
        <option value="250">250</option>
        <option value="300">300</option> 
        <option value="350">350</option> 
        <option value="400">400</option>
        <option value="500">500</option> 
        <option value="600">600</option> 
        <option value="700">700</option>
        <option value="750">750</option> 
        </select>  <br>
        <b>Conduit Size</b><br>
        <select id="cond">
        <option value="1">1/2</option> 
        <option value="2">3/4</option> 
        <option value="3">1</option>
        <option value="4">1-1/4</option> 
        <option value="5">1-1/2</option> 
        <option value="6">2</option>
        <option value="7">2-1/2</option> 
        <option value="8">3</option> 
        <option value="9">3-1/2</option>
        <option value="10">4</option> 
        <option value="11">5</option> 
        <option value="12">6</option>
        </select><br><br>
        <input type="button" value="Wires allowed" onclick="fillcap();" > 
        </form>
</body>
</html>

 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing values out awk.

found that passing (input) values to awk, all work well. For example: errpt | awk 'BEGIN { errore=0 } substr($2,1,4) /'ParamData'/ { .... } ' ParamData=`date +"%m%d"` Now I wish to obtain (output) a value. Using this method is it possible to re-write ParamData, for example? Thanks in... (3 Replies)
Discussion started by: gio123bg
3 Replies

2. Shell Programming and Scripting

Passing FORM(HTML) variable to ksh

I am currently able to use the $QUERY_STRING variable and simply cut out what I need to be assigned as variables within the shell script. However, I've been able to use the "name" value assigned within the FORM(HTML) as a variable when I use perl. Why is it that ksh doesn't read the "name" in as... (1 Reply)
Discussion started by: douknownam
1 Replies

3. Shell Programming and Scripting

Passing Bash variable to javascript

How do I pass a bash variable to a javascript? I've tried #!/bin/bash echo "Content-type: text/html" echo "" echo "<html>" echo "<head>" counter=0 echo '<script> window.parent.document.forms.counter.value = "$counter"; </script>' I have an iframe script which I am trying to pass a... (3 Replies)
Discussion started by: numele
3 Replies

4. Shell Programming and Scripting

Javascript or HTML to retrieve apache username

I have a internal wesbite set up and any visitor must enter username / passwd as defined in apache (I've set these up using htpasswd) I use cgi scripts set up using ksh or javascript to populate pages / tables etc. I want to be able to get the apache username that the used authorised... (3 Replies)
Discussion started by: frustrated1
3 Replies

5. Programming

Looking For the Best Way to Rotate an Image: JavaScript, PHP, HTML etc

Hey All, What I'm looking for is a way to rotate an image by non 90 degree angles (ie 90, 180, 270, 360). I am able to do it in PHP, but there are errors in the image, some pixels end up colored incorrectly and the image ends up resized and I lose transparency. I've done my share of searching on... (1 Reply)
Discussion started by: pmd006
1 Replies

6. Programming

javascript average from from values in radiobuttons?

Hi all, can you please help me with these part of my code, I want to calculate average grade from each module and not sure if need to label each element there, or is there any easier option to do that? appreciate your help... (0 Replies)
Discussion started by: me.
0 Replies

7. Shell Programming and Scripting

How to get values from href in HTML to sh

Hi, This is a part of my code: case "$1" in home) echo '<h2> Select a student: </h2>' echo '<br>' for stunum in $(ls ./) do echo "<a href=edit?numeric_stu=$stunum>`sed -n 1p ./$stunum/info`</a>" echo '<br>' done edit)... (1 Reply)
Discussion started by: jerrywangzi
1 Replies

8. Web Development

Web development learning thread(Javascript, HTML, CSS, angular, vue.js).

Hello All, After getting inspired from Neo, I have started a bit of JS learning these days. Whenever I learn something I will try to post it here(as of now my learning is NOT exactly bookish where I am going chapter by chapter etc, it could be more like small-small project vice kind of), I... (25 Replies)
Discussion started by: RavinderSingh13
25 Replies
Data::JavaScript::Anon(3pm)				User Contributed Perl Documentation			       Data::JavaScript::Anon(3pm)

NAME
Data::JavaScript::Anon - Dump big dumb Perl structs to anonymous JavaScript structs SYNOPSIS
# Dump an arbitrary structure to javascript Data::JavaScript::Anon->anon_dump( [ 'a', 'b', { a => 1, b => 2 } ] ); DESCRIPTION
Data::JavaScript::Anon provides the ability to dump large simple data structures to JavaScript. That is, things that don't need to be a class, or have special methods or whatever. The method it uses is to write anonymous variables, in the same way you would in Perl. The following shows some examples. # Perl anonymous array [ 1, 'a', 'Foo Bar' ] # JavaScript equivalent ( yes, it's exactly the same ) [ 1, 'a', 'Foo Bar' ] # Perl anonymous hash { foo => 1, bar => 'bar' } # JavaScript equivalent { foo: 1, bar: 'bar' } One advantage of doing it in this method is that you do not have to co-ordinate variable names between your HTML templates and Perl. You could use a simple Template Toolkit phrase like the following to get data into your HTML templates. var javascript_data = [% data %]; In this way, it doesn't matter WHAT the HTML template calls a particular variables, the data dumps just the same. This could help you keep the work of JavaScript and Perl programmers ( assuming you were using different people ) seperate, without creating cross-dependencies between their code, such as variable names. The variables you dump can also be of arbitrary depth and complexity, with a few limitations. ARRAY and HASH only Since arrays and hashs are all that is supported by JavaScript, they are the only things you can use in your structs. Any references or a different underlying type will be detected and an error returned. Note that Data::JavaScript::Anon will use the UNDERLYING type of the data. This means that the blessed classes or objects will be ignored and their data based on the object's underlying implementation type. This can be a positive thing, as you can put objects for which you expect a certain dump structure into the data to dump, and it will convert to unblessed, more stupid, JavaScript objects cleanly. No Circular References Since circular references can't be defined in a single anonymous struct, they are not allowed. Try something like Data::JavaScript instead. Although not supported, they will be detected, and an error returned. MAIN METHODS
All methods are called as methods directly, in the form "Data::JavaScript::Anon->anon_dump( [ 'etc' ] )". anon_dump STRUCT The main method of the class, anon_dump takes a single arbitrary data struct, and converts it into an anonymous JavaScript struct. If needed, the argument can even be a normal text string, although it wouldn't do a lot to it. :) Returns a string containing the JavaScript struct on success, or "undef" if an error is found. var_dump $name, STRUCT As above, but the "var_dump" method allows you to specify a variable name, with the resulting JavaScript being "var name = struct;". Note that the method WILL put the trailing semi-colon on the string. script_wrap $javascript The "script_wrap" method is a quick way of wrapping a normal JavaScript html tag around your JavaScript. is_a_number $scalar When generating the javascript, numbers will be printed directly and not quoted. The "is_a_number" method provides convenient access to the test that is used to see if something is a number. The test handles just about everything legal in JavaScript, with the one exception of the exotics, such as Infinite, -Infinit and NaN. Returns true is a scalar is numeric, or false otherwise. You may also access method in using an instantiated object. new HASH This will create a Data::JavaScript::Anon object that will allow you to change some of the default behaviors of some methods. Options: quote_char : Set the quote_char for stirng scalars. Default is '"'. SECONDARY METHODS
The following are a little less general, but may be of some use. var_scalar $name, $scalar Creates a named variable from a scalar reference. var_array $name, @array Creates a named variable from an array reference. var_hash $name, \%hash Creates a named variable from a hash reference. anon_scalar $scalar Creates an anonymous JavaScript value from a scalar reference. anon_array @array Creates an anonymous JavaScript array from an array reference. anon_hash \%hash Creates an anonymous JavaScript object from a hash reference. anon_hash_key $value Applys the formatting for a key in a JavaScript object SUPPORT
Bugs should be reported via the CPAN bug tracker at: http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-JavaScript-Anon <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-JavaScript-Anon> For other comments or queries, contact the author. AUTHOR
Adam Kennedy <adamk@cpan.org> SEE ALSO
JSON, <http://ali.as/> COPYRIGHT
Copyright 2003 - 2009 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of the license can be found in the LICENSE file included with this module. perl v5.14.2 2012-03-26 Data::JavaScript::Anon(3pm)
All times are GMT -4. The time now is 04:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy